Edit report at https://bugs.php.net/bug.php?id=60997&edit=1

 ID:                 60997
 Updated by:         il...@php.net
 Reported by:        eric at wepay dot com
 Summary:            getopt() parses optional values incorrectly
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            CGI/CLI related
 Operating System:   Linux CentOS
 PHP Version:        5.3.10
 Block user comment: N
 Private report:     N

 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php




Previous Comments:
------------------------------------------------------------------------
[2012-02-07 03:45:22] carloschilazo at gmail dot com

Documentation also states: 

Note: Optional values do not accept " " (space) as a separator.

------------------------------------------------------------------------
[2012-02-06 23:51:51] eric at wepay dot com

Description:
------------
If a CLI argument is passed with leading whitespace, the value is not picked up 
by 
getopt() if specified as an optional value (with two colons). This is contrary 
to 
the documentation, which states, "Option values are the first argument after 
the 
string. It does not matter if a value has leading white space or not."

Test script:
---------------
<?php

var_dump(getopt('v'));
var_dump(getopt('v:'));
var_dump(getopt('v::'));


?>


$ ./test.php -v2 asdf   # behaves as expected
$ ./test.php -v=2 asdf  # behaves as expected
$ ./test.php -v 2 asdf  # problem case, shown in actual result


Expected result:
----------------
array(1) {
  ["v"]=>
  bool(false)
}
array(1) {
  ["v"]=>
  string(1) "2"
}
array(1) {
  ["v"]=>
  string(1) "2"
}


Actual result:
--------------
array(1) {
  ["v"]=>
  bool(false)
}
array(1) {
  ["v"]=>
  string(1) "2"
}
array(1) {
  ["v"]=>
  bool(false)
}



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=60997&edit=1

Reply via email to