What PHP can do
PHP Official document Don't facePHP can do anything it, this and the industry widely circulated to kill other programmers do not life isPHP is the best language really remote call corresponding.
PHP is mainly used in the following three areas
(1) server-side scripting
This is the main area where PHP parsers (CGI or server modules) are used with Web servers (such as Apache, Nginx).
(2) Command line script
In this way, only the PHP parser is required to execute. LenovoPythonwill understand.
(3) Desktop applications
With some extensionsPHP-GTK, you can use PHP to write desktop applications. But how boring it is to do it.
Command-line development
The following actions are performed under a Mac
Enter thephpdirectory, orphpplace the directory in the environment variable. (Mac ignores this step)
View the PHP engine
php -v
# output
PHP 5.5.27 (cli) (built: Jul 23 2015 00:21:59)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
View Use Help
php -h
# Output
Usage: php [options] [-f] [-] [args ...]
php [options] -r [-] [args ...]
php [options] [-B] -R [-E] [-] [args ...]
php [options] [-B] -F [-E] [-] [args ...]
php [options] -S: [-t docroot]
php [options]-[args ...]
php [options] -a
-a Run as interactive shell
-c Look for php.ini file in this directory
-n No php.ini file will be used
-d foo [= bar] Define INI entry foo with value 'bar'
-e Generate extended information for debugger / profiler
-f Parse and execute.
-h This help
-i PHP information
-l Syntax check only (lint)
-m Show compiled in modules
-r Run PHP without using script tags
-B Run PHP before processing input lines
-R Run PHP for every input line
-F Parse and execute for every input line
-E Run PHP after processing all input lines
-H Hide any passed arguments from external tools.
-S: Run with built-in web server.
-t Specify document root for built-in web server.
-s Output HTML syntax highlighted source.
-v Version number
-w Output source with stripped comments and whitespace.
-z Load Zend extension.
args ... Arguments passed to script. Use-args when first argument
starts with-or script is read from stdin
--ini Show configuration file names
--rf Show information about function.
--rc Show information about class.
--re Show information about extension.
--rz Show information about Zend extension.
--ri Show configuration for extension.
Execute a PHP file
php [-f] xxx.php
Can pass parameters
php [-f] xxx.php 'hello' 'world' 2015
The parameters passed to the script can be obtained in the global variable $ argv. The global variable $ argc stores the number of member variables in the $ argv array (instead of the number of parameters passed to the script program).
001.php
Execute 001.php
php 001.php 'hello world' 2015
output
php -r 'echo Hello World
;'
#output Hello World
You can also run PHP code directly
php -r 'echo Hello World;' #Hello World