Passing arguments on the commandline

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
Paul Oertel
Forum Newbie
Posts: 18
Joined: Fri May 31, 2002 3:44 am
Location: Japan

Passing arguments on the commandline

Post by Paul Oertel »

I want to pass some arguments to a PHP script from the commandline.

The code looks like this:

Code: Select all

<$php

$param = $argv&#1111;1];
echo $param;

?>
When I run it I get the following result:

Code: Select all

E:\PHP>php -f "m:\reportnt.php" Thisisaparameter

PHP Notice:  Undefined variable:  argv in m:\reportnt.php on line 24

E:\PHP>
Am I doing something wrong here?

Paul
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

Try using $_SERVER[argv] and if you need, $_SERVER[argc].

Later on,
BDKR (TRC)
Post Reply