HTML vs PHP in plain English

The difference between HTML and PHP in one sentence:

HTML is the code required for a web page to show up in your web browser; PHP is the code that changes the HTML code.

Assuming you're familiar with the basics of HTML¹, the simplest way to understand what purpose in life PHP¹ serves is to think of it like this:

When you create a basic web page (using HTML, of course), you personally determine what will show up when your web page is viewed: the background color, the font color, any images, etc -- and if someone wants to see a different image (or color or whatever) on your web page, they'll basically have two choices:

  • They can either call you and tell you to change the page; or,
  • Accept it the way it is and just live with it. Period. Just like houses don't clean their own floors, web pages don't change their own content. Without assistance.

For most people, "clean carpets" means "getting out the vacuum and vacuuming." Many people have roommates, kids, spouses, etc., who they can ask to do the vacuuming for them. Some people have housekeepers who they can tell to do the vacuuming for them. A few might even have robots that vacuum. Either way, most people can do it themselves if/when there's no one else around.

The point is, regardless of which individual person (or thing) actually performs the work, there's always going to be an individual person (or thing). Note: If you know of an exception to this rule, I'd advise you to stop reading this -- as in now -- and go start your own "miracle cleaning" business. You'll make millions.

With all that said (and since you're still here, apparently) here's the message: your web page is the floor that needs to be cleaned; your computer is the vacuum that cleans the floors; you are the lucky individual (or thing) who would have to perform the work normally, except now you have a new roommate who will do all the work for you -- and that person (or thing)'s name is PHP.

In short, PHP is not by any means "the same thing as" HTML, but rather a separate language that tells HTML what to do (aka what to display on a web page) depending on who's viewing the page, where they're viewing it from, what button they clicked, what time of day they clicked the button, and so on. So rather than your friend having to call you and ask you to change the picture on your web page from sun.jpg to moon.jpg (since it's nighttime), all they have to do is hit the refresh button and PHP will take care of it for you. (Incidentally, telling time is one of PHP's specialties.)

Hope that helps someone...
Any feedback is more-than-welcome, too. :)

¹See the next page for definitions, but please remember that the section you're in is called Plain English Programming.

Thanks for letting us know.

Thanks for letting us know. Any further updates on this planned in future?

Steve
www.purelyhydroponic.com

Hey thanks...great

Hey thanks...great explanations...
Just wondering what will happen if an HTML code is pasted within a HOME.PHP page of a website ???
I'm not sure, but this could be the reason I'm not able to verify my websites with Yahoo! & Bing, because I'm pasting their HTML verification codes on my sites home.php pages...who knows???
I only have access to this page, I don't know about any HTML code of the home page.

Here's what will happen

Whatever HTML code you paste into the file named HOME.PHP should show the same exact results that you would get if you pasted that same code into any file ending in .html. Keep in mind though that file names themselves are (usually) case-SeNsiTiVE, so most of the time it's a good idea to name the file using all lowercase letters (e.g. home.php instead of HOME.PHP).

As far as the Google/Bing verification thing goes, they usually require you to create an entirely new file before they'll confirm your site as being "verified". There are a few reasons they do this, but the primary reason is because when you create that new file, it shows them that you are authorized to make new files (which is usually a good indication that you either own or administer the site). So unfortunately, if what you're trying to do is verify your site by copying/pasting their HTML code into the HOME.PHP file, that alone probably won't do you much good.

At the same time, if you are not able to create a new file, there are other ways to do it. For example, you could try copying/pasting this code into your HOME.PHP file (no guarantees, though):

<?php
$directory_of_HOME_dot_PHP_file = dirname(__FILE__);
 
$name_of_file_to_create = 'insert_the_name_of_the_file_here.html';
 
$where_to_put_the_file = "$directory_of_HOME_dot_PHP_file";
$where_to_put_the_file .= "/$name_of_file_to_create";
 
$html_that_needs_to_go_inside_the_new_file = "<p>Paste your
HTML code here.<br/>You can add as many lines as you want...
Just don't forget to \"escape\" \"double-quotes\" (since your
HTML is wrapped in \"double-quotes\").<br/>:)</p>";
 
$technical_stuff = "cat << EOF > $where_to_put_the_file
$html_that_needs_to_go_inside_the_new_file
EOF
";
 
shell_exec($technical_stuff);
 
print "Click <a href=\"$name_of_file_to_create\">here</a>";
print " to see if it worked.";
?>

I loved this difference very

I loved this difference very much... But I like html among them..

Thanks for sharing

Thanks for sharing Interesting post. Thanks for taking this opportunity to discuss this, I appreciate with this and I like learning about this subject. If possible, as you gain information, please update this blog with more information. I have found it really useful.
Frigidaire FGHD2433KF

Thanks for spamming.

... not.
"Fail".

hey nice information , thank

hey nice information , thank you for the post.

Thanks

Thank you for that explanation. That helps a lot.

Cheers,

Mike

:)

I'm new to this (PHP/HTML

I'm new to this (PHP/HTML language)and I am so glad that I came across your article because it really is in Plain english. Other articles I came across were not as straight to the point as you were. Thanks for the article

Thanks for the article

Your straight-forward style of writing is attractive. When googling "php vs html", this is exactly what I needed to find. Nice analogies, too. :)

Post new comment

The content of this field is kept private and will not be shown publicly (unless you post spam, in which case it will potentially be shown all over the place).
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <ascode>, <as3code>, <csscode>, <jscode>, <phpcode>.

More information about formatting options