Click to See Complete Forum and Search --> : php.exe command line & post parameters


Anon
04-20-2002, 05:31 AM
hi!
i want to execute php scripts in command line. I want to learn how i can send values to a script variable externally from command line.
for example:

test.php
------
<?
echo $param;
?>
------

command line:
c:\php\php.exe c:\test.php param=test

when i execute above command nothing is written on screen. param variable failed to obtain the "test" value.
Is sending a value to a variable in a script from command line possible ?

Thanks for your replies.

Anon
04-20-2002, 02:25 PM
Yes its possible just different

c:\php\php.exe c:\test.php test

then

<?php
echo $argv[1];
?>

Anon
07-06-2002, 02:52 AM
Just export a environment variable 'QUERY_STRING' with your details in it... ie, (on UNIX)

# export QUERY_STRING="foo=bar&blah=1243123"
# php -q phptest.php
foo = bar
blah = 1243123

Under DOS/Windows I think you only really need to do 'SET QUERY_STRING="...."'