PHP Tutorials - Herong's Tutorial Examples - v5.17, 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
PHP Data Types and Data Literals
Variables, References, and Constants
Expressions, Operations and Type Conversions
Conditional Statements - "if" and "switch"
Loop Statements - "while", "for", and "do ... while"
Function Declaration, Arguments, and Return Values
Interface with Operating System
Introduction of Class and Object
Integrating PHP with Apache Web Server
Retrieving Information from HTTP Requests
Creating and Managing Sessions in PHP Scripts
Sending and Receiving Cookies in PHP Scripts
Controlling HTTP Response Header Lines in PHP Scripts
MySQL Server Connection and Access Functions
Functions to Manage Directories, Files and Images
SOAP Extension Function and Calling Web Services
SOAP Server Functions and Examples
Localization Overview of Web Applications
Using Non-ASCII Characters in HTML Documents
Using Non-ASCII Characters as PHP Script String Literals
Receiving Non-ASCII Characters from Input Forms
"mbstring" Extension and Non-ASCII Encoding Management
Managing Non-ASCII Character Strings with MySQL Servers
Parsing and Managing HTML Documents
Configuring and Sending Out Emails
Managing PHP Engine and Modules on macOS