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!
echo
doesn't output to screen, it outputs to the stream received by the browser. This includes all text you can see, but also links, images, etc.
You can see what the browser gets by using "View page source" in your browser.