I'm trying to write down a script to fetch some online data; script should be invoked either by a cron job or php cli and with standard GET HTTP request. As stated on PHP website $_SERVER['argv']
should fit my needs:
Array of arguments passed to the script. When the script is run on the command line, this gives C-style access to the command line parameters. When called via the GET method, this will contain the query string.
However i can't get it to work with standard HTTP GET request. $_SERVER['argv']
is not setted. What i'm missing?
<?php
// jobs/fetch.php
var_dump($_SERVER['argv']);
?>
CLI output php jobs/fetch.php -a -bhello
:
array(3) {
[0]=>
string(14) "jobs/fetch.php"
[1]=>
string(2) "-a"
[2]=>
string(7) "-bhello"
}
GET output jobs/fetch.php?a=&b=hello
:
See Question&Answers more detail:osNotice: Undefined index: argv in jobs/fetch.php.