ID:               36091
 Updated by:       [EMAIL PROTECTED]
-Summary:          getopt() returns false on every call (works with PHP
                   5.1)
 Reported By:      oli at isnic dot is
-Status:           Open
+Status:           Feedback
 Bug Type:         *General Issues
 Operating System: FreeBSD 5.4
 PHP Version:      4.4.2
 New Comment:

This works just fine for me:

test.php:

#!sapi/cli/php
<?php
$options = getopt("b:s");
var_dump($options);
?>

#./t.php -s -b 1
array(2) {
  ["s"]=>
  bool(false)
  ["b"]=>
  string(1) "1"
}

Works the same with both 5.1.2 and 4.4.2.
Try this same script please. (change the hashbang path, of course :)


Previous Comments:
------------------------------------------------------------------------

[2006-01-19 18:05:43] oli at isnic dot is

Description:
------------
The "fix" in bug #35594 breaks getopt() in PHP4 completely
on my system, it returns false on every call now.
 
FreeBSD 5.4-RELEASE-p8 and php-4.4.2 updated today.
 
Removing the "fix" makes getopt() work again.


Reproduce code:
---------------
$options = getopt("b:s");

if (!$options) {
  print("\$options is false\n");
}
else {
  foreach ($options as $key => $value) {
    if ($value) {
      print($key."=".$value."\n");
    }
    else {
      print($key."=false\n");
    }
  }
}
exit(0);


Expected result:
----------------
#./getopt.php -s -b 1
s=false
b=1


Actual result:
--------------
#./getopt.php -s -b 1
$options is false



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


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

Reply via email to