Sometimes you can't or don't want to install php-cgi,您没有编辑php文件的选项可以将$_GETset as parameters passed in.
$act=$_GET['act'];
if ($act){
$act = $argv[1];
}
You can access the variables of your startup script from the $argvarray in your php application. The first entry will be the name of the script they came from
This will avoid changing your php文件,并允许您使用plain php命令。如果你安装了php-cgi, be sure to use this
-r表示在以下字符串中运行php代码。您手动设置$_GET value and then reference the file to run.
It's worth noting that you should run this file in the correct folder, usually but not always php文件所在的文件夹。Requires the statement will use the location of your command to resolve the relative URL, not the location of the file
Normally speaking, $_GET and $argv should not appear together. One is for web execution and the other is for command line execution. But after searching just now, it seems that get can be passed through php-cgi. Click here to view.
$act=$_GET['act']; is to get the string xxxx after act=xxxx on the url. $act = $argv[1] obtains the second parameter value in the command line.
The logic of the code here is to first get the parameters from the url, and if the parameters have values, then reassign them. So the last $act of this code is the value of $argv[1]. This php file can only be called from the command line!
It is suggested that the poster should change it instead of mixing them. It is recommended to use argv on the command line, get post request, etc. It is better to use them separately.
Sometimes you can't or don't want to install
php-cgi
,您没有编辑php文件的选项可以将$_GET
set as parameters passed in.You can access the variables of your startup script from the
$argv
array in your php application. The first entry will be the name of the script they came fromThis will avoid changing your
php
文件,并允许您使用plain php
命令。如果你安装了php-cgi
, be sure to use this-r
表示在以下字符串中运行php
代码。您手动设置$_GET
value and then reference the file to run.It's worth noting that you should run this file in the correct folder, usually but not always
php
文件所在的文件夹。Requires
the statement will use the location of your command to resolve the relative URL, not the location of the file$_GET, generally stores
query string
的key=>value
arrays. In principle, it is read-only, but assignment is also possible, but it is not recommended.Normally speaking, $_GET and $argv should not appear together. One is for web execution and the other is for command line execution. But after searching just now, it seems that get can be passed through php-cgi. Click here to view.
$act=$_GET['act']; is to get the string xxxx after act=xxxx on the url. $act = $argv[1] obtains the second parameter value in the command line.
The logic of the code here is to first get the parameters from the url, and if the parameters have values, then reassign them. So the last $act of this code is the value of $argv[1]. This php file can only be called from the command line!
It is suggested that the poster should change it instead of mixing them. It is recommended to use argv on the command line, get post request, etc. It is better to use them separately.