$_SERV array and warning messages.

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
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

$_SERV array and warning messages.

Post by BDKR »

Hey people,

I've been doing a good share of batch scripting and work with PHP as a server lately. One of the things I've noticed is that I can't just use $argc / $argv. But, I can use $_SERV[argc] / $_SERV[argv]. However, I am encountering issues even with this. For example....

Code: Select all

echo "$_SERVERїargvї1]]\n";
.... causes the script to blow up with "... parse error, unexpected '[', expecting ']'..... Now if argv is an array of command line arguments, then shouldn't the above be correct? As well, if I use...

Code: Select all

echo $_SERVERїargv]ї1];
.... it blows up even faster with a "... use of undefined constant argv - assumed 'argv' ...."

Now I've been able to deal with the above with this code here.

Code: Select all

@$argc = $_SERVERїargc];
@$argv = $_SERVERїargv];
However, I get the feeling this isn't the best code in the world. Anybody else have any comment or experience along these lines?

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

Post by BDKR »

OK, ..... Now I feel stupid. The trick was much easier than it should've been. I don't know I why I didn't consider or see it before.

The below code works fine...

Code: Select all

echo $_SERVERїargv]ї1];
.... if you put argv in "'s. Doh!

Code: Select all

echo $_SERVERї"argv"]ї1];
Sorry to take up bandwidth..... :oops:
BDKR
Post Reply