Getting argv[1] using php-cgi

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
topaz
Forum Newbie
Posts: 1
Joined: Thu Mar 15, 2007 10:45 am

Getting argv[1] using php-cgi

Post by topaz »

From the command prompt in windows, if I run ‘php.exe test.php arg1’ from the CLI I can retrieve arg1 using $argv[1] inside of test.php

However, if I run ‘php-cgi.exe test.php arg1’ I get the error ‘Undefined index: argv’

What is the proper way to retrieve args from inside your php code using php-cgi.exe?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Why do you use php-cgi.exe when you want the functionality of cli?
User avatar
stereofrog
Forum Contributor
Posts: 386
Joined: Mon Dec 04, 2006 6:10 am

Post by stereofrog »

Have you tried $_SERVER['argv'] ?
Post Reply