Computer Magic
Software Design Just For You
 
 



PHP Tutorial – Lesson 2 HTML Vs. PHP

Time for the second session of our PHP Programming Tutorial. This time around, I am going to attempt to explain the differences between what PHP does, and what HTML does. For many, the line between static web content (HTML) and dynamic web content (HTML mixed with PHP) is fuzzy.

1) HTML is for display ONLY!!!
2) PHP is for CODE ONLY… NO DISPLAY!!!

The GUI (Graphical User Interface) for a PHP app IS HTML! Without this, PHP would be nothing but a nice console. Lets illustrate this with a simple PHP script.



<?php
print "PHP Rocks!!!";
?>
<BR>
<B>HTML is cool too!!!</B>

The <B> tags around the HTML phrase makes it look pretty. Take those away and all you are left with is the text. If your PHP Print statements added some <B> tags around the statement “PHP Rocks!!!” it would make it bold. Not because PHP had anything to do with it, but because the web browser would recognize those tags and render the text accordingly:

 <?php
print "<B>PHP Rocks!!!</B>";
?>

Remember, PHP makes it work, HTML makes it pretty!

Lastly, I want to mention the difference between HTML in a PHP section (inside the PHP tags) and HTML outside a PHP section. When you open a PHP tag, the PHP parser expects ALL statements it encounters to be valid PHP code. HTML is NOT PHP and the PHP engine does not understand it. Any and ALL data (data is anything that isn’t PHP code) should be enclosed in the “s. Failure to do so will result in errors. Try leaving off a quote, or putting the “<B> tags outside the ” and see what happens.

It is very common for PHP to output HTML to help beautify the results and you should familiarize yourself with this process if you want to be a successful web developer.

Ray Pulsipher

Owner

Computer Magic And Software Design

Comments are closed.


Home | My Blog | Products | Edumed | About Us | Portfolio | Services | Location | Contact Us | Embedded Python | College Courses | Quick Scan | Web Spy | EZ Auction | Web Hosting
This page has been viewed 830553 times.

Copyright © 2005 Computer Magic And Software Design
(360) 417-6844
computermagic@hotmail.com
computer magic