Question: Say we usually it access via

```
http://localhost/index.php?a=1&b=2&c=3

```

How do we execute the same on a 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`? I doubt that'll work.

Answer: 
From this [answer on Server Fault](https://serverfault.com/a/187038):

Use the `php-cgi` binary instead of just `php`, and pass the arguments on the command line, like this:

```
php-cgi -f index.php left=1058 right=1067 class=A language=English

```

Which puts this in `$_GET`:

```
Array
(
    [left] => 1058
    [right] => 1067
    [class] => A
    [language] => English
)

```

You can also set environment variables that would be set by the web server, like this:

```
REQUEST_URI='/index.php' SCRIPT_NAME='/index.php' php-cgi -f index.php left=1058 right=1067 class=A language=English

```
If you have the possibility to edit the PHP script, you can artificially populate the `$_GET` array using the following code at the beginning of the script and then call the script with the syntax: `php -f script.php name1=value1 name2=value2`

```
// When invoking the script via CLI like 
// "php -f script.php name1=value1 name2=value2", 
// this code will populate $_GET variables called 
// "name1" and "name2", so a script designed to 
// be called by a web server will work even 
// when called by CLI
if (php_sapi_name() == "cli") {
    for ($c = 1; $c < $argc; $c++) {
        $param = explode("=", $argv[$c], 2);
        $_GET[$param[0]] = $param[1]; // $_GET['name1'] = 'value1'
    }
}

```