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: 
Typically, for passing arguments to a command line script, you will use either the `argv` global variable or [getopt](http://php.net/getopt):

```
// Bash command:
//   php -e myscript.php hello
echo $argv[1]; // Prints "hello"

// Bash command:
//   php -e myscript.php -f=world
$opts = getopt('f:');
echo $opts['f']; // Prints "world"

```

`$_GET` refers to the HTTP GET method parameters, which are unavailable on the command line, since they require a web server to populate.

If you really want to populate `$_GET` anyway, you can do this:

```
// Bash command:
//   export QUERY_STRING="var=value&arg=value" ; php -e myscript.php
parse_str($_SERVER['QUERY_STRING'], $_GET);
print_r($_GET);
/* Outputs:
     Array(
        [var] => value
        [arg] => value
     )
*/

```

You can also execute a given script, populate `$_GET` from the command line, without having to modify said script:

```
export QUERY_STRING="var=value&arg=value" ; \
php -e -r 'parse_str($_SERVER["QUERY_STRING"], $_GET); include "index.php";'

```

Note that you can do the same with `$_POST` and `$_COOKIE` as well.
### Option 1: php-cgi

Use 'php-cgi' in place of 'php' to run your script. This is the simplest way as you won't need to specially modify your PHP code to work with it:

```
php-cgi -f /my/script/file.php a=1 b=2 c=3

```

### Option 2: If you have a web server

If the PHP file is on a web server you can use 'wget' on the command line:

```
wget 'http://localhost/my/script/file.php?a=1&b=2&c=3'

```

*Or*:

```
wget -q -O - "http://localhost/my/script/file.php?a=1&b=2&c=3"

```

### Accessing the variables in PHP

In both option 1 & 2, you access these parameters like this:

```
$a = $_GET["a"];
$b = $_GET["b"];
$c = $_GET["c"];

```