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.
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:
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.
Computer Magic And Software Design