Analyze the application of argc argv in php

  • 2020-06-19 09:53:33
  • OfStack

argc,argv is useful when compiling programs from the command line
We will find this parameter in the timer task script, $obj- > run($argv[1]);
*/30 * * * * /usr/local/bin/php /htdocs/test.com/uaqm/commands/test.php 1 > /dev/null 2 > & 1
Like the timing task above, if we call it with the parameter $argv[1], that represents the first string in the script after executing the program name on the DOS command line
The red 1 in the script above, if we deploy the timed 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
So we think of this task as having three processes running, which means that the pressure becomes 1/3 of the original, and that makes sense

Here are the official explanations for these two keywords.
argc: Integer that counts the number of command-line arguments you send to the main function when you run the program
* argv: String array, which holds an array of Pointers to your string arguments, with each element pointing to one argument
argv[0] points to the full pathname of the program to run
argv[1] points to the first string after executing the program name on the DOS command line
argv[2] points to the second string after the name of the executing program
NULL argv [argc]


Related articles: