- slide 1 of 5
A Brief Introduction to HTML
HTML, or Hypertext Markup Language, came about as a simple language designed to communicate information effectively through browsers. HTML is easy to code, and is still the only Internet computer language that all browsers are guaranteed to understand. Newer languages need parsing engines, which turn the code into HTML for browsers to understand.
HTML is a static programming language, whereas most newer ones are dynamic. A static language means that the code does not change under any circumstances. It neither reacts to events on the web page, nor does it display selectively. As a matter of fact, HTML is not really considered a true programming language because it merely tells the browser how to display certain text.
- slide 2 of 5
A Little about PHP
PHP, short for PHP Hypertext Pre-processor, is a web scripting language used to provide dynamic content to web pages. The rules of the language are not stringent, allowing for a great deal of flexibility.
PHP scripts are embedded in HTML code, and the file name is changed to a .php extension. The scripts in the page are processed on the web server where the website is hosted, and then sent to the user’s browser as HTML. In this way, the browser does not require a php parsing engine of its own.
- slide 3 of 5
Converting PHP to HTML using PHP Editors
The easiest way to convert PHP to HTML is to use a PHP editor or website creator. In a PHP editor, all coding is done in one window, and the output of that code is shown in a second window. The editor comes with an in-built PHP parsing engine, mimicking one that would usually be resident on a server.
The output of PHP parsing is in HTML; therefore the editor is capable of converting PHP code into HTML. Most editors will have an option to generate the HTML version of a PHP program.
However, a potential disadvantage of converting code automatically from PHP to HTML is that the resultant code may be unwieldy and messy. Most editors interpret things like comments or functions differently, resulting in HTML code that may not be predictable. The results will also vary significantly depending on the editor.
- slide 4 of 5
Conversion using Browsers
A quick and easy way of converting PHP code into HTML is to open the PHP pages in a browser and then save the web page. The web page saves as an HTML file, and the associated files are stored in a folder with the same name. To edit the HTML code, the HTML can be opened in an editor.
This method is practically foolproof, however it suffers from the same disadvantage as the previous method. The results tend to vary depending on the browser, and the generated HTML code is usually unwieldy.
- slide 5 of 5
Converting PHP code manually to HTML may be a tedious task, but it is perhaps the most reliable method of getting optimized code. Analyzing the flow of the webpage and then recoding it in HTML will yield the best results.
It is also possible to use one of the automatic conversion methods initially, and then go over the resultant code manually to fine tune it. The initial automated draft may suffer from all the disadvantages of its method, but it will preclude the need to analyse the flow in PHP first. The code can be tidied up by a programmer in the second phase of a conversion cycle.