#29714 [Opn->Csd]: getopt does not reset
| From: | tony2001@php.net | Date: | Mon, 03 Apr 2006 12:02:15 +0000 |
| Subject: | #29714 [Opn->Csd]: getopt does not reset | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-95279@lists.php.net to get a copy of this message | ||
ID: 29714
Updated by: tony2001@php.net
Reported By: lists at cyberlot dot net
-Status: Open
+Status: Closed
Bug Type: Feature/Change Request
Operating System: Fedora Core 2
PHP Version: 5.0.0
New Comment:
Fixed in 5.1.2
Previous Comments:
------------------------------------------------------------------------
[2004-08-17 01:05:09] lists at cyberlot dot net
Description:
------------
You can only call getopt a single time and get results. Getopt should
reset what ever pointers it uses to ensure state is as it was prior to
calling getopt.
An example.. A modular based system using a config file or command line
to load a module, It is impossible for the module to use getopt to look
for module specific settings because getopt has already been called by
the main engine.
./engine -loadmod abc -abcdb 123
It is impossible for mod abc to realize it needs to load database 123
because any attempts to run getopt based on those new params fail.
Reproduce code:
---------------
<?
$cl_input = getopt('c:h');
print_r($cl_input);
$cl_input = getopt('c:h');
print_r($cl_input);
?>
Expected result:
----------------
[root@fs streams]# php test.php -c 1
Array
(
[c] => 1
)
Array
(
[c] => 1
)
Actual result:
--------------
[root@fs streams]# php test.php -c 1
Array
(
[c] => 1
)
Array
(
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=29714&edit=1