Re: How to set GET and POST variables through CLI?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Any parameters passed from the command line go to the $argv array, but
you cannot specify the key ( they are put in the order in which they
appear ). So calling:

php.exe foo.php "foo1" "foo2"

would call foo.php and $argv would have:

0 => 'foo.php'
1 => 'foo1'
2 => 'foo2'

I suppose you could have something in front of the file that read the
arguments and put them into the $_GET array.

On 8/22/07, Steve Francisco <cisco@xxxxxxxxxx> wrote:
> Hi, I'd like to use the command line interface to test my php files
> before I put them live.  However I can't figure out how to pass
> variables so the php program sees them as if they came in via an HTTP
> GET request.
>
> For example, if the url would be this on the server:
>         http://some.server.com/mypage.php?parm1=Hello&parm2=Goodbye
> and in mypage.php I do something like this:
>         $echo $_GET["parm1"];
> then how do I test this via the PHP command line?
>
> Am I missing something simple?  I tried this but it doesn't work:
>         php.exe -f mypage.php -- parm1=Hello parm2=Goodbye
>
> Thanks for any help.
> -- Steve
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
-- 
John Mertic                                        "Explaining a joke
is like dissecting a frog: you
jmertic@xxxxxxxxx                              understand it better,
but the frog dies in the
                                                          process."

                      -Mark Twain

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux