PHP Command line functionality...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
icarpenter
Forum Commoner
Posts: 84
Joined: Mon Mar 07, 2005 8:12 am
Location: Kent, England

PHP Command line functionality...

Post by icarpenter »

Hi

I am trying to execute a PHP script from the commandline but I am having a few issues passing values into the script?

Can anyone help?

know this is wrong but I am trying to push a value into the script, this is what I type from the command line on the server:

Code: Select all

C:\php\php.exe C:\test.php --"$test=value;"
I am trying to catch the value and echo this out to the terminal...this is test.php:-

Code: Select all

echo $test;
Any help would be greatly appreciated!

Thanks Ian
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

A CLI call would look something like:

php.exe myscript.php argument1 argument2

Arguments do not need to be preceded by any character (a dash or otherwise), and all passed arguments are stored in order in the $_SERVER['argv'] array.
User avatar
icarpenter
Forum Commoner
Posts: 84
Joined: Mon Mar 07, 2005 8:12 am
Location: Kent, England

Post by icarpenter »

Thats got it!!!

Many thanks aaronhall!!!
Post Reply