Our First Script

Let’s jump right in with a PHP script. To begin, open your favorite text editor. Like HTML documents, PHP files are made up of plain text, so you can create them with any text editor, such as Notepad and HomeSite on Windows, Simple Text and BBEdit on Mac OS, or VI and Emacs on Unix operating systems. Most popular HTML editors provide at least some support for PHP.

Keith Edmunds maintains a handy list of PHP-friendly editors at http://phpeditors.linuxbackup.co.uk.

Type in the example in Listing 3.1 and save the file. We’ll name our file listing3.1.php.

Listing 3.1. A First PHP Script
1: <?php
2: phpinfo();
3: ?>

The code in ...

Get Sams Teach Yourself PHP in 24 Hours, Third 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.