Running PHP Scripts

This section describes how to run PHP scripts in a command window in normal mode and in CGI mode.

PHP scripts can be executed with two different command interfaces:

To do a quick test with both interfaces, I wrote the following simple script, hello.php, with a text editor:

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

I used the \local\php\php.exe to execute this script in a command window:

C:\>\local\php\php hello.php
Hello world!

I then the \local\php\php-cgi.exe to execute this script in a command window:

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

Hello world!

PHP CGI, php-cgi.exe, generated the HTTP response header as required by the Web server.

To learn more about running PHP scripts, read my other book: PHP Tutorials - Herong's Tutorial Notes

Last update: 2015.

Table of Contents

 About This Book

PHP Installation on Windows Systems

 Download and Install PHP 5.2.2 on Windows

Running PHP Scripts

 Integrating PHP with Apache Web Server

 charset="*" - Encodings on Chinese Web Pages

 Chinese Characters in PHP String Literals

 Multibyte String Functions in UTF-8 Encoding

 Input Text Data from Web Forms

 Input Chinese Text Data from Web Forms

 MySQL - Installation on Windows

 MySQL - Connecting PHP to Database

 MySQL - Character Set and Encoding

 MySQL - Sending Non-ASCII Text to MySQL

 Retrieving Chinese Text from Database to Web Pages

 Input Chinese Text Data to MySQL Database

 References

 PDF Printing Version