query string value from php command line
I have a question about using php from the command line.
I want to be able to call the php interpreter from the command line and pass values from the query string to the script.
Say I want to test a page that needs a session id to generate properly. From the browser I type in
how can I get the session_id to be recognized by my script that expects the variable to be instantiated when it parses the query string?
I've tried setting the QUERY_STRING environment variable and then running php (at least in windows) and that doesn't seem to work.
c:\> set QUERY_STRING id=12345
c:\> php.exe myscript.php
I've tried passing variables as additional arguments (which seems the most intuitive to me)
c:\> php.exe myscript.php session_id=12345
There has to be an easy way to do this. Anyone know how?
RE: query string value from php command line
Easy answer! There was a PHPBuilder on this subject:
Using PHP As A Shell Scripting Language
RE: query string value from php command
Thanks. I was able to import the shell variable QUERY_STRING in linux, but I suspect my problem in windows must have been needing to set the php.ini file:
I found this help at:
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)