By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,296 Members | 1,457 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,296 IT Pros & Developers. It's quick & easy.

parameters and commandline

P: n/a
hi
i want to start a php programm from commandline and pass some parameters to
the programm. but the programm did not recognize the parameters.

the commandline ist: php liste.php para1=one para2=two

the source (list.php)

....
echo $_request[para1];
echo $_request[para2];
....

why does this not work?

Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

Alexander Gausa wrote:
hi
i want to start a php programm from commandline and pass some parameters to the programm. but the programm did not recognize the parameters.

the commandline ist: php liste.php para1=one para2=two

the source (list.php)

...
echo $_request[para1];
echo $_request[para2];
...

why does this not work?


When using PHP from the command line you need to use the array $argv.
The $_REQUEST superglobal is only available when running via a web
server.

For example:
cmdline.php contains:
<?
print_r ($argv);
?>

When run from the command line:
php -q cmdline.php para1=one para2=two

The results are:
Array
(
[0] => cmdline.php
[1] => para1=one
[2] => para2=two
)
Ken

Jul 17 '05 #2

P: n/a
Thanks, it is working!

Ken Robinson wrote:

Alexander Gausa wrote:
hi
i want to start a php programm from commandline and pass some

parameters to
the programm. but the programm did not recognize the parameters.

the commandline ist: php liste.php para1=one para2=two

the source (list.php)

...
echo $_request[para1];
echo $_request[para2];
...

why does this not work?


When using PHP from the command line you need to use the array $argv.
The $_REQUEST superglobal is only available when running via a web
server.

For example:
cmdline.php contains:
<?
print_r ($argv);
?>

When run from the command line:
php -q cmdline.php para1=one para2=two

The results are:
Array
(
[0] => cmdline.php
[1] => para1=one
[2] => para2=two
)
Ken


Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.