HTML, PHP and the program that serves pages
HTML is the markup language of the web. It uses tags to say what each part of a page is: a heading, a paragraph, a picture, a link. PHP is a different tool for a different job. It is a free, open-source language for the server, and its code is written inside the HTML of a file that ends in .php. (The letters first meant “Personal Home Page”; today they stand for “PHP: Hypertext Preprocessor”. Treat both as just a name.) Who does what? The browser asks for the page. The web server program receives the request, finds the .php file and hands it to the PHP engine, which runs the PHP parts and leaves the HTML parts alone. What comes out is plain HTML, and that is all the browser receives. Note that PHP is run, not “translated” into something else for the browser. To write all this code you need only a plain text editor; fancier code editors just make typing easier.
1<p>The club has <?php echo 3 + 4; ?> new books.</p><p>The club has 7 new books.</p>
| Job | Tool |
|---|---|
| write the code | plain text editor |
| receive the request | web server program |
| run the PHP parts | PHP engine |
| show the page | browser |
Draw the journey of one request for books.php on paper: four boxes with arrows. Under each box write who does the work and what moves along the arrow (a request, a file, plain HTML). Mark the box that the visitor never sees.