PHP Modules Tutorials - Herong's Tutorial Examples - v5.18, by Herong Yang
"php -a" - PHP Interactive Shell
This section provides a tutorial example on how to run the PHP engine as an interactive shell, php -a, which lets you to type in a PHP statement and see the result immediately on the screen.
In previous tutorial, I learned how to run the PHP engine to execute a PHP script stored in a file.
The PHP engine can also be used as an interactive shell, taking PHP script from the console and execute it one line at a time. interactively.
Here is a session of running the PHP engine as an interactive shell:
herong> \php\php -a Interactive shell php > print "I am tossing a coin...\n"; I am tossing a coin... php > $coin = rand(0,1); php > if ($coin==1) { php { print " Head\n"; php { } else { php { print " Tail\n"; php { } Head php > exit C:\herong>
Cool. This is really a good tool to help leaning PHP. Just typing in a PHP statement, and watching the result displayed immediately on the screen.
Table of Contents
►Introduction and Installation of PHP
Downloading and Installing PHP 7.3 for Windows
"php -help" - Command Line Options
"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
DOM Module - Parsing HTML Documents
GD Module - Manipulating Images and Pictures
MySQLi Module - Accessing MySQL Server
OpenSSL Module - Cryptography and SSL/TLS Toolkit
PCRE Module - Perl Compatible Regular Expressions
SOAP Module - Creating and Calling Web Services
SOAP Module - Server Functions and Examples