Home  >  Article  >  Backend Development  >  Detailed explanation and application of PHP command line parameters_PHP tutorial

Detailed explanation and application of PHP command line parameters_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:30:001080browse

Copy code The code is as follows:

# Execution format without parameters
php installation directory/bin/php scriptname.php
# Execution format with parameters
php installation directory/bin/php scriptname.php [parameter 1] [parameter 2] .....
Access parameters through $argv and $argc in scriptname.php
# The $argv (formally written as $_SERVER['argv']) array stores all the parameters passed. It should be noted that the first parameter $argv[0] / $_SERVER['argv'][0] is the execution The name of the script is like, scriptname.php
# $argc (formally written as $_SERVER['argc']) saves the number of parameters


When the user opens the php page, the service The client executes PHP commands and sends the execution results to the user's browser. This is similar to ASP and CoildFusion. PHP can run on WINDOWS and multiple versions of UNIX. In addition to being able to manipulate your pages, PHP can also send HTTP headers.
You can set cookies, manage digital signatures and redirect users, and it provides excellent connectivity to other databases (also ODBC), integrating various external libraries to do anything from parsing XML with PDF documents. Then did you know that you can use the powerful functions of php to do other things? When running in independent cgi mode, a php executable program is required. It has many command line parameters, some of which can be used for fun purposes. The following are all php command line parameters, where [] indicates that they are optional. Yes, the <> table is a must. Usage php [-q] [-h] [-s] [-v] [-i] [-f ] | { [args...]} -q Quiet mode. Do not output HTTP headers.
-s Convert PHP program files to HTML in color format (for example, reserved words are in green, functions and variables are in blue, comments are in yellow and strings are in red, etc.)
-f Read and merge Interpret the specified file.
-c Read the php.ini file in
-a Interactively run
-d foo[=bar] Define the value of the input item foo in ini to be bar
-e Output additional information for debugging and performance analysis
-z Load Zend extension file
-i php related information
-h help itself.
1. Use php -q file name.php. The method is to use the php program as a shell program.
2. Use -s to html your own php program. Isn’t this very worry-free?
3. Use the odbc function of php to run the database in the shell command. Perform operations.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323319.htmlTechArticleCopy the code code as follows: # Execution format without parameters php installation directory/bin/php scriptname.php # With Parameter execution format php installation directory/bin/php scriptname.php [Parameter 1] [Parameter 2...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn