Basic Syntax

As I mentioned in the book’s introduction, PHP is an HTML-embedded scripting language. What HTML-embedded means precisely is that you can intermingle PHP and HTML code within the same script.

Script 1.1 gives an example of a no-frills XHTML Transitional document, which I’ll be using as the foundation for every Web page in the book. To place PHP code within this document, you surround the code with PHP tags, either the formal (XML style)

<?php
?>

or the informal

<?
?>

Anything placed within these tags will be treated by the Web server as PHP (meaning the PHP interpreter will process the code rather than it being immediately sent to the Web browser).

A final consideration for your PHP scripts is that the file must use an extension ...

Get PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.