Basic Syntax

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

To begin programming with PHP, start with a simple Web page. 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 (see Appendix C, “Resources,” for information on XHTML).

Script 1.1. A basic XHTML 1.0 Transitional Web document.

To place PHP code within this document, you surround the code with PHP tags, either the formal and preferred

<?php

?>

or the informal

Get PHP and MySQL for Dynamic Web Sites: Visual Quickpro Guide, Second Edition 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.