# PHP $_GET Command Line



## benzrf (Feb 26, 2009)

I want to test my PHP scripts without putting them online, and without setting up my computer as a server. So I found out about running them through the command line. However, I CAN'T figure out how to send it GET or POST data. If a server can send it GET data, why can't I do so over the command line?

P.S. I'm new to this, so please keep any explanations as simple as possible!


----------



## MMJ (Oct 15, 2006)

benzrf said:


> If a server can send it GET data, why can't I do so over the command line?


Because GET & POST were made for HTTP servers.

Use command line arguments to pass data to your program.

http://php.net/features.commandline


----------



## benzrf (Feb 26, 2009)

OK... See, I wrote a script that I want to test, but the free hosting service I normally use was down. Now it's back up, but if it happens again... I want to be able to test my scripts without modifying them. Isn't there some way to pass $_GET or $_POST over the command line? Don't servers do that? Not to repeat myself, but again, if a server can do it, why can't I?

Thanks anyway, though.


----------



## JimmySeal (Sep 25, 2007)

I don't know enough about the PHP interpreter to answer the why part of your question, but here is a potential workaround:

http://bytes.com/groups/php/491693-passing-_post-variables-command-line-php


----------



## MMJ (Oct 15, 2006)

Just download an Apache/PHP/MySQL package.

I use http://appservnetwork.com


----------

