PHP Tutorials - Herong's Tutorial Examples
Dr. Herong Yang, Version 3.00

Hello.php - My First PHP Script

This section provides a tutorial example on how to write the first PHP script, Hello.php, and run it with PHP CLI and PHP CGI.

Use any text editor like notepad, and enter the first PHP script, Hello.php:

Hello <?php echo "world!"; ?>

Run it with PHP CLI first:

>\php\php Hello.php
Hello world!

Then run it with PHP CGI:

>\php\php-cgi Hello.php
Content-type: text/html
X-Powered-By: PHP/5.0.4

Hello world!

As expected, both versions of the PHP engine worked nicely. PHP CGI version did generate the HTTP response header for me.

Last update: 2007.

Sections in This Chapter

What Is PHP?

Downloading and Installing PHP 5.0.4 for Windows

Downloading and Installing PHP 5.2.2 for Windows

"php -help" - Command Line Options

"php -m" - Compiled-in Modules

"php -i" - PHP Engine Information

Hello.php - My First PHP Script

Adding PHP to IIS as CGI

Dr. Herong Yang, updated in 2009
Hello.php - My First PHP Script