|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-08-26 18:37 UTC] b8kich at gmail dot com
Description:
------------
When only long options are required in getopt (without any short options), they are not captured.
Found this in 5.3.15 (CentOS 5.8) and confirmed in 5.4.6 (CentOS 6.3)
Test script:
---------------
script.php:
<?php
$longopts = array(
"required:", // Required value
"optional::", // Optional value
"option", // No value
"opt", // No value
);
$options = getopt("", $longopts);
var_dump($options);
?>
Expected result:
----------------
The long options should be captured even if there are not short ones:
array(3) {
["required"]=>
string(5) "value"
["optional"]=>
string(14) "optional value"
["option"]=>
bool(false)
}
Actual result:
--------------
$ php script.php -f "value for f" --required value --optional="optional value" --option
array(0) {
}
Throwing in some short options does not help either:
$ php script.php -f "value for f" -v -a --required value --optional="optional value" --option
array(0) {
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 21 21:00:01 2025 UTC |
I am not having any problems with this: $ php -v PHP 5.4.6RC1 (cli) (built: Aug 30 2012 20:24:11) (DEBUG) $ php ../tests/issue-62940.php --required value --optional="optional value" -- option array(3) { ["required"]=> string(5) "value" ["optional"]=> string(14) "optional value" ["option"]=> bool(false) } Can you please provide the _exact_ command you are using for calling the script?