Edit report at https://bugs.php.net/bug.php?id=62940&edit=1
ID: 62940 Comment by: lonnyk at gmail dot com Reported by: b8kich at gmail dot com Summary: getopt does not support long options without short options Status: Open Type: Bug Package: PHP options/info functions Operating System: Linux (Centos 6.3) PHP Version: 5.4.6 Block user comment: N Private report: N New Comment: 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? Previous Comments: ------------------------------------------------------------------------ [2012-08-26 18:37:45] 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) { } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=62940&edit=1