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:

herong> \php\php Hello.php

Hello world!

Then run it with PHP CGI:

herong> \php\php-cgi Hello.php

X-Powered-By: PHP/7.3.0
Content-type: text/html; charset=UTF-8

Hello world!

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

But note that the "Content-type" in PHP 7.3 is set to "UTF-8", which is different than PHP 5.6. See output from PHP 5.6:

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

Hello world!

Table of Contents

 About This Book

Introduction and Installation of PHP

 What Is PHP

 Downloading and Installing PHP 7.3 for Windows

 "php -help" - Command Line Options

 "php -m" - Built-in Modules

 "php -i" - PHP Engine Information

 php.ini - PHP Runtime Configuration

Hello.php - My First PHP Script

 "php -a" - PHP Interactive Shell

 Downloading and Installing PHP Documentation

 Managing PHP Engine and Modules on macOS

 Managing PHP Engine and Modules on CentOS

 MySQLi Module - Accessing MySQL Server

 DOM Module - Parsing HTML Documents

 GD Module - Manipulating Images and Pictures

 Zip Module - Managing ZIP Archive Files

 SOAP Module - Creating and Calling Web Services

 SOAP Module - Server Functions and Examples

 References

 Full Version in PDF/EPUB