ads



When you view a webpage, the server (i.e. the site you are viewing) sends a bunch of HTML to your computer. Your browser (Firefox, Safari, Internet Explorer, whatever) then turns this HTML source into the pretty stuff you see in your browser.

With pure HTML, every visitor to a website will see the same thing, no matter what. For example, if I make an HTML page with this content:

<p>Today is December 1st, 2007<⁄p>

...everyone at my site will see this:
Today is December 1st, 2007
...even if it is not December 1st, 2007. What if you want to modify that so it always shows the current date? That's where PHP comes in. PHP is processed by your server (i.e. by the site you are visiting). The server evaluates any PHP in the page before sending anything to your browser. So if I write this in my webpage:

<p>Today is <?php echo date('F jS, Y'); ?><⁄p>

Then the server will change that PHP expression into the current date, then send that as HTML to your browser, which then does its part. Remember: The server processes PHP, but the browser processes HTML. PHP does not get sent to the browser, only the HTML that the PHP produces. That's important. So important that I'll say it again.
PHP does not get sent to the browser, only the HTML that the PHP produces.

People sometimes wonder why their theme's index.php file looks nothing like the HTML source they see in their browser.

0 comments:

Post a Comment

 
Top