Command line setting _GET and _POST?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I am writing some test harnesses for my php scripts. Ideally I would
like to be able to execute scripts from the command line.

This seems to be doable, (i.e. php.exe c:\test.php )

Is it possible to set the contents of the _GET and _POST arrays when
calling a script from the command line?


Re: Command line setting _GET and _POST?

Mark Smith escribió:
Quoted text here. Click to load it

As far as I know, $_GET and $_POST are never read-only. But PHP won't
fill them for you: if there is no HTTP involved, there aren't any get or
post parameters. In command line you have command line parameters,
standard input, files...

-- - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web:
-- Mi web de humor al baño María:

Re: Command line setting _GET and _POST?

Quoted text here. Click to load it

As Álvaro stated, HTTP requests determine the contents of the
$_GET/$_POST superglobals.

You might write your test harness to send HTTP requests to your
scripts with the desired inputs.  You could wrap this up in a few
classes so you can easily test from the command line or on a Web
server with a single interface.

$email = str_replace('sig.invalid', '', $from);

Anonymous (1984 IOCCC winner):
int i;main()"];read('-'-'-',i+++"hell\
o, world!\n",'/'/'/'));}read(j,i,p)

Site Timeline