Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Command Line PHP variable

Posted on 2011-09-11
5
Medium Priority
?
349 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 82

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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

618 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