Say we usually access via
http://localhost/index.php?a=1&b=2&c=3
How do we execute the same in linux command prompt?
php -e index.php
But what about passing the $_GET variables? Maybe something like php -e index.php --a 1 --b 2 --c 3? Doubt that'll work.
Thank you!
Typically, for passing arguments to a command line script, you will use either
argv
global variable or getopt:$_GET refers to the HTTP GET method parameters, which are unavailable in command line, since they require a web server to populate.
If you really want to populate $_GET anyway, you can do this:
You can also execute a given script, populate
$_GET
from the command line, without having to modify said script:Note that you can do the same with
$_POST
and$_COOKIE
as well.