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

 ID:                 50244
 Updated by:         [email protected]
 Reported by:        craig dot marvelley at boxuk dot com
 Summary:            getopt() does not reset
-Status:             Open
+Status:             Bogus
 Type:               Bug
 Package:            *General Issues
 Operating System:   *
 PHP Version:        5.3.3
 Block user comment: N
 Private report:     N

 New Comment:

It's not about resetting, it's about how getopt() works:



>From the manual: "Note: The parsing of options will end at the first
non-option found, anything that follows is discarded."



Your second call encounters the passed '-d hello' which you have
specified as not being included in the args, thus it's an error.


Previous Comments:
------------------------------------------------------------------------
[2010-10-18 20:34:40] alexc223 at googlemail dot com

I can also confirm this on PHP 5.3.3

------------------------------------------------------------------------
[2009-11-20 14:37:31] craig dot marvelley at boxuk dot com

Description:
------------
A bug that has been reported and fixed in the past regarding getopt not


resetting after being called once has resurfaced.



Here's the original bug: http://bonsai.php.net/bug.php?id=29714



The same behaviour is happening in 5.3.1 - once getopt has been called,


subsequent calls ignore options not included in the original call.





Reproduce code:
---------------
> php test.php -d hello -b world



<?php

$options = getopt("d:");

print_r($options);



$options = getopt("b:");

print_r($options);

Expected result:
----------------
Array 

(

    [d] => hello

)



Array 

(

    [b] => world

)

Actual result:
--------------
Array 

(

    [d] => hello

)



Array 

(

)


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



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

Reply via email to