|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9289 Command line argument list inaccurate
Submitted: 2001-02-15 14:48 UTC Modified: 2001-05-07 20:53 UTC
From: reinke at e-softinc dot com Assigned:
Status: Closed Package: Unknown/Other Function
PHP Version: 4.0.4pl1 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: reinke at e-softinc dot com
New email:
PHP Version: OS:


 [2001-02-15 14:48 UTC] reinke at e-softinc dot com
PHP, when being run from the command line, has been mangling
the command line arguments badly for some while. It would be
nice if they mapped to the same usage as C programs.

PHP4.04pl1 is particularly bad - argc is completely broken:

Consider the script
<? printf("%d\n", $argc); ?>

Here's the output from php4.01, and then from php4.04pl1

$ php -f test.php
$ php -f test.php a
$ php -f test.php a b
$ php -f test.php a b c

$ /home/webapps/webserver/bin/php404pl1 -f test.php
$ /home/webapps/webserver/bin/php404pl1 -f test.php a
$ /home/webapps/webserver/bin/php404pl1 -f test.php a b
$ /home/webapps/webserver/bin/php404pl1 -f test.php a b c

As you can see, argc is never less than 2, and in fact is a value
of 2 with zero args or one arg (bad bad bad!).

Sort of important for us - we find PHP SO EASY to program in,
that we actually use it as the language of choice, even for batch
programming, when performance is not absolutely critical.
But it sort of makes it tough to pass in cmd line arguments...


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-05-07 20:30 UTC]
Reproducable under Win2k.

- James
 [2001-05-07 20:53 UTC]
Fixed in the CVS - thanks for the report!

Note that
./php -f foo.php
sets $argc to 1, like
./php foo.php
does.  Old versions of PHP erroneously set it to 0.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Jul 05 10:05:45 2022 UTC