php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #18566 comand line argument parsing with +
Submitted: 2002-07-25 11:35 UTC Modified: 2002-12-26 20:03 UTC
Votes:2
Avg. Score:3.0 ± 2.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: goba@php.net Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.2.1 OS: Windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: goba@php.net
New email:
PHP Version: OS:

 

 [2002-07-25 11:35 UTC] goba@php.net
I have tries the following script (test.php):

    <?php var_dump($argv); ?>

With:

    php test.php a b c

and the results are:

    array(4) {
      [0]=>
      string(8) "test.php"
      [1]=>
      string(1) "a"
      [2]=>
      string(1) "b"
      [3]=>
      string(1) "c"
    }

What was new to me, is that

    php test.php a+b+c

produces the same ;) So if this is intentional,
then it should be documented at least ;)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-25 11:41 UTC] goba@php.net
The same effect is reproduceable with:

    php test.php a=b=c
    php test.php a;b;c

Goba
 [2002-08-13 07:17 UTC] sander@php.net
Is this still valid with the CLI? Or are you talking about the CGI executable?
(Can't reproduce it with the CLI on Linux)
 [2002-08-13 07:21 UTC] goba@php.net
I tested this with the CGI one, probably it's not a problem with the CLI.
 [2002-08-13 07:26 UTC] edink@php.net
This was one of the reasons CLI was created in the first place - to get rid of all CGI specific (mis)features.

This issue should probably be mentioned in the command line chapter.
 [2002-08-13 08:01 UTC] holliwell at gmx dot net
with cgi-version(4.2.1, win2k):

test.php a b c

array(4) {
  [0]=>
  string(8) "test.php"
  [1]=>
  string(1) "a"
  [2]=>
  string(1) "b"
  [3]=>
  string(1) "c"
}
php test.php a+b+c
array(4) {
  [0]=>
  string(8) "test.php"
  [1]=>
  string(1) "a"
  [2]=>
  string(1) "b"
  [3]=>
  string(1) "c"
}

php test.php a=b=c

array(2) {
  [0]=>
  string(8) "test.php"
  [1]=>
  string(5) "a=b=c"
}

php test.php a;b;c

array(2) {
  [0]=>
  string(8) "test.php"
  [1]=>
  string(5) "a;b;c"
}

Only a+b+c seems to bahave "strange".

with cli-version(4.2.1,win2k):

php-cli test.php a b c
array(4) {
  [0]=>
  string(8) "test.php"
  [1]=>
  string(1) "a"
  [2]=>
  string(1) "b"
  [3]=>
  string(1) "c"
}

php-cli test.php a+b+c
array(2) {
  [0]=>
  string(8) "test.php"
  [1]=>
  string(5) "a+b+c"
}

php-cli test.php a=b=c
array(2) {
  [0]=>
  string(8) "test.php"
  [1]=>
  string(5) "a=b=c"
}

php-cli test.php a;b;c
array(2) {
  [0]=>
  string(8) "test.php"
  [1]=>
  string(5) "a;b;c"
)

The same results for cgi and cli version in 4.2.2 on win.
Only a+b+c seems to be strange with the cgi.

Friedhelm
 [2002-08-13 08:09 UTC] goba@php.net
Ups, I double checked my PHP version and it as 4.1.2 and not 4.2.1, so I had more strange behaviours with the CGI version... Seems like some things were corrected between 4.1.2 and 4.2.1...
 [2002-08-13 08:36 UTC] holliwell at gmx dot net
with cgi 4.1.2 on win i get only strange results for a+b+c

php test.php a+b+c
array(4) {
  [0]=>
  string(8) "test.php"
  [1]=>
  string(1) "a"
  [2]=>
  string(1) "b"
  [3]=>
  string(1) "c"
}
 [2002-12-26 20:03 UTC] edink@php.net
This is how CGI binary works. Use CLI (in the cli folder as of 4.3.0) if you don't want those "strange" results.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Sep 19 14:01:28 2024 UTC