hrolsons
asked on
Command Line PHP variable
I am able to issue command line php such as:
C:\>php test.php
And everything runs fine.
But, when I try to send a variable:
C:\>php test.php?my_variable=hello
It fails with a:
Could not open input file test.php?my_variable=hello
Where am I going wrong?
C:\>php test.php
And everything runs fine.
But, when I try to send a variable:
C:\>php test.php?my_variable=hello
It fails with a:
Could not open input file test.php?my_variable=hello
Where am I going wrong?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
"test.php?my_variable=hell o" is something a web server would recognize as a URL with a query string. That is not the way it is done on the command line because the command line version does not run thru the web server. I think you need to come to an understanding of the difference because you have several questions here that confuse those two different ways of running PHP.
Instead of running PHP from the command line, I always put my scripts on my web server and test them there, over the internet, in the live environment that is exactly where they will run, when they are released into the wild. It saves me a lot of confusion. You might want to think about that. My "build process" usually consists of Save->Ftp->Refresh. Lather, rinse, repeat. Easy!
ASKER
Ray,
I totally see what you're saying, but in this case, the php file is manipulating images(adding the border), and will never leave my machine.
I totally see what you're saying, but in this case, the php file is manipulating images(adding the border), and will never leave my machine.
http://www.techrepublic.com/article/control-your-scripts-with-command-line-php/5889263
http://stackoverflow.com/questions/974356/run-php-script-from-command-line-with-variable