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:\herong> \local\php\php hello.php
Hello world!

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

>\php\php-cgi Hello.php
X-Powered-By: PHP/7.3.0
Content-type: text/html; charset=UTF-8

Hello world!

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

Congratulations, PHP engine is stalled and working!

To learn more about running PHP scripts, read my other book: "PHP Tutorials - Herong's Tutorial Examples at herongyang.com/PHP

Table of Contents

 About This Book

PHP Installation on Windows Systems

 Download and Install PHP 7.3.0 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

 Chinese Text Encoding Conversion and Corruptions

 Archived Tutorials

 References

 Full Version in PDF/EPUB