When executing a php file as a cmd command line, pass parameters

Source: Internet
Author: User
1. PHP comes with two parameters $ARGC, $ARGV: 1.1. $ARGV:

(The following v is the meaning of variables), and the arguments passed in are kept in this variable in the form of an array.

1.2. $ARGC:

(The following C is the meaning of count), keeping the number of arguments in the $ARGV, which is not an array

2. Example: 2.1. PHP Code:
<?php   if ($argc ==0)  echo "Here is no args";  else  echo $ARGC;    Print_r ($ARGV);? >
2.2. Operation Result:

From the visible, even if the direct input PHP file.php This way, the number of parameters is not 0,file.php is also considered a parameter

Then, the arguments passed in are separated by a space, so the general parameters are obtained from the $ARGV [1].

When executing a php file as a cmd command line, pass parameters

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.