Analysis of ARGC argv application in PHP _php skills

Source: Internet
Author: User
Tags first string

ARGC,ARGV useful when compiling programs with the command line
We will find such parameters in the timed 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 timer task above, if we call him with the parameter $argv[1], that means the first string that executes the program name in the DOS command line in the script
That's the Red 1 in the script above, 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
So we think that this task is running in three processes, which means that the pressure becomes the original one-third, so it's easy to understand.

The official explanations for these two keywords are released below.
ARGC: Integer that counts the number of command-line arguments you give to the main function when you run the program
* argv: A string array that holds an array of pointers to your string arguments, each of which points to a parameter
Argv[0] point to the full path name of the program running
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 executing the program name
ARGV[ARGC] is null

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.