Home > Backend Development > PHP Tutorial > Application of parsing argc argv in php_PHP tutorial

Application of parsing argc argv in php_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-21 15:04:05
Original
1304 people have browsed it

argc, argv are useful when compiling programs from the command line
We will find such parameters in the scheduled task script, $obj->run($argv[1]);
*/30 * * * * /usr/local/bin/php /htdocs/test.com/uaqm/commands/test.php 1 >/dev/null 2>&1
Just like the scheduled task above, If we add the parameter $argv[1] when calling him, it means that the first string
after the program name is executed on the DOS command line in the script is the corresponding red string in the above script. That 1, if we deploy the scheduled tasks listed below
*/30 * * * * /usr/local/bin/php /htdocs/test.com/uaqm/commands/test.php 1 >/dev /null 2>&1
*/30 * * * * /usr/local/bin/php /htdocs/test.com/uaqm/commands/test.php 2 >/dev/null 2>&1
*/30 * * * * /usr/local/bin/php /htdocs/test.com/uaqm/commands/test.php 3 >/dev/null 2>&1
Then we think this task is divided into three A process is running, which means that the pressure becomes one-third of the original, so it is easy to understand

The official explanations of these two keywords are released below.
argc: integer, used to count the number of command line parameters sent to the main function when you run the program
* argv: string array, used to store an array of pointers pointing to your string parameters , each element points to a parameter
argv[0] points to the full path name of the program running
argv[1] points to the first string after the program name is executed on the DOS command line
argv[2 ] Points to the second string
after the execution program name argv[argc] is NULL

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327799.htmlTechArticleargc,argv is useful when compiling the program from the command line. We will find such parameters in the scheduled task script, $obj -run($argv[1]); */30 * * * * /usr/local/bin/php /htdocs/test.com/uaqm/comma...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template