ID:               36091
 Updated by:       [EMAIL PROTECTED]
 Reported By:      oli at isnic dot is
 Status:           Assigned
 Bug Type:         CGI related
 Operating System: FreeBSD 5.4
 PHP Version:      5.1.2, 4.4.2
 Assigned To:      iliaa
 New Comment:

Changing optind re-initalization to optind = 1; fixes it for me on
FreeBSD (and works on Linux).
Though it still makes we wonder why FreeBSD prefers to have its own
implementation of everything: for some reasons they also have `extern
int optreset;`, but it doesn't make any difference whether you change
it or not.


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

[2006-01-20 11:31:09] [EMAIL PROTECTED]

Ilia, this is propably some issue on FreeBSD, I can't reproduce with
Linux.

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

[2006-01-20 10:39:47] oli at isnic dot is

Same result, I also tried with -n so that nothing was being 
taken from the php.ini, and again it works fine when 
compiled without the forementioned "fix"

# cat t.php 
#!/usr/local/bin/php
<?php
$options = getopt("b:s");
var_dump($options);
?>
# ./t.php -s -b 1
array(0) {
}

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

[2006-01-19 20:46:40] [EMAIL PROTECTED]

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 :)

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

[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