Writing PHP Code

With PHP up and running on your server, you are ready to begin writing PHP scripts. All you need to do this is a simple text editor, such as Notepad in Windows or vi on a UNIX machine.

Basic Syntax Rules

You read earlier that PHP code coexists with XHTML code in the same file. The PHP instructions are parsed out and executed by the PHP scripting engine. To make it easy for the scripting engine to find your PHP code, you must enclose it in special delimiters. These take this form:

<?php
   ... PHP code ...
?>
						

Tip

If you're an astute XML developer, you might be wondering whether the PHP code delimiters might conflict with an XML processing instruction. XML processing instructions are enclosed by the <? and ?> delimiters. You can ...

Get Platinum Edition Using XHTML™, XML, and Java™ 2 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.