?
Solved

Command Line PHP variable

Posted on 2011-09-11
5
Medium Priority
?
364 Views
Last Modified: 2012-05-12
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?
0
Comment
Question by:hrolsons
5 Comments
 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 36520721
>Where am I going wrong?

the system try to find the file test.php?my_variable=hello (and not file test.php as you want)
C:\>php test.php hello

Open in new window


in you code (test php) :
<?PHP

echo $_SERVER["argv"][1];

?>

Open in new window

0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 36520962
"test.php?my_variable=hello" 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.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 36521703
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!
0
 

Author Comment

by:hrolsons
ID: 36523859
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.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This holiday season, we’re giving away the gift of knowledge—tech knowledge, that is. Keep reading to see what hacks, tips, and trends we have wrapped and waiting for you under the tree.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses
Course of the Month15 days, 19 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question