Forum Moderators: coopster

Message Too Old, No Replies

PHP from command line

php index.php q=test?

         

moltar

10:43 pm on Apr 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I need to run php script from command line for debugging. I also need to pass a GET string. How can I do this? I tried the following:

$> php index.php q=test

but it didn't work.

JollyK

10:47 pm on Apr 3, 2006 (gmt 0)

10+ Year Member



If your shell is bash:

export QUERY_STRING="q=p&blah=whatever"

If your shell is tcsh:

setenv QUERY_STRING "q=p&blah=whatever"

The environment variable QUERY_STRING is what's generally used for GET requests.

POST is a little harder, but this method works for me in almost everything I need to test.

JK

moltar

11:02 pm on Apr 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As a matter of fact now that I tried my first approach it worked. Passing the arguments on the command line works fine.

My problem was elsewhere - the DOCUMENT_ROOT env var was not defined, and some template file was not loading correctly.