$ARGV and $ARGC configuration methods in PHP scripts

Source: Internet
Author: User
This article mainly introduces the command line to execute PHP script $argv and $ARGC methods, this article gives you a very detailed introduction, the need for friends can refer to, hope to help everyone.

In the actual work may encounter the need to execute PHP script in the Nginx command line, of course, you can configure a conf to use the external network access.

Use in the Nginx command line

php index.php

You can execute the index.php script, but how do you pass the parameters? That will use $ARGV and $AEGC. You do not have to turn on what settings are used directly in the script, similar to HTTP $_post and $_get in the value of the pass:

Do you want to insert the following dishes in index.php


<?phpecho $argv [0];     echo "\ n"; Var_dump ($argv [1]);    echo "\ n"; Var_dump (Intval ($argv [2]);  echo "\ n"; echo $argv [3];     echo "\ n"; Echo $argc;

And then use it on the Nginx command line.


PHP index.php 1 10 100

Show


index.php//$ARGV [0] Display results tested here is the relative path to the execution position (that is, where you entered the PHP index.php, which shows the location of index.php relative to your current directory) string (1) "1" $ARGV [1] shows that the first parameter will be converted to a string int (ten)//$ARGV [2] Display the second parameter of [+//$ARGV [3] shows the second parameter 4//$ARGV the number of parameters relative to the path + you pass the Parameters

For the sake of memory, check this variable.$avgv 为 argument vector, $avgc 为 argument count

Related Article

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.