Wordpress echo site_url() - why use echo?

Wordpress echo site_url() - why use echo?
0

#1

Hi,
I’ve just begun learning php and WordPress functions. I have a question regarding the use of ‘echo’ and would appreciate it if someone can help me.

If ‘echo’ is used to output data to the screen, why do we use echo site_url() or echo site_url(’/blog’) in the a href tag when all we want is attach a link to the anchor text? The url isn’t outputted/printed on the screen.

Thanks in advance!


#2

Correct me if I’m wrong, but depending on context, echo may be outputting to your html file.


#3

Thanks, Kevin.
Sorry if the original query was confusing. Part of it was missing and I’ve just edited it.
Oh, I see. I think I know what you’re getting at. I’ll look into what echo really does then.
Thank you.


#4

Hi
I just want to add this in case someone else has the same question. So I asked around and found out that echo outputs to the browser (rather than the screen) and we can see the output when we view the page source. Without echo, the browser would not be able to interpret the value returned by a function. The value would then be ignored upon rendering of the page.
Thanks!