|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-03-31 15:41 UTC] hradtke@php.net
[2009-04-01 11:34 UTC] jani@php.net
[2009-04-01 13:44 UTC] rquadling@php.net
[2009-12-16 22:40 UTC] svn@php.net
[2009-12-16 22:42 UTC] j dot boggiano at seld dot be
[2009-12-17 12:10 UTC] svn@php.net
[2009-12-17 12:13 UTC] seld@php.net
[2009-12-25 00:27 UTC] kalle@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 19:00:01 2025 UTC |
Description: ------------ getopt() stops processing at the first unknown parameter. I'm not sure if this is ... a php bug - getopt should return them as is or ... a doc bug - getopt() will cease operation at the first hurdle. My preference is to return them as is. Maybe a third param to the function to collect unknown parameters. This would provide backward compatibility if the function didn't die when an unknown parameter was reached. The code is a simple test to examine the command line. Run this with this parameter -a 1 and then with these broken -a 1 Reproduce code: --------------- <?php var_dump($_SERVER['argv'], getopt('a:b', array('apple=', 'bag'))); ?> Expected result: ---------------- array(3) { [0]=> string(17) "C:\phpargtest.php" [1]=> string(2) "-a" [2]=> string(1) "1" } array(1) { ["a"]=> string(1) "1" } array(4) { [0]=> string(17) "C:\phpargtest.php" [1]=> string(6) "broken" [2]=> string(2) "-a" [3]=> string(1) "1" } array(1) { [0]=> string(6) "broken" ["a"]=> string(1) "1" } Actual result: -------------- array(3) { [0]=> string(17) "C:\phpargtest.php" [1]=> string(2) "-a" [2]=> string(1) "1" } array(1) { ["a"]=> string(1) "1" } array(4) { [0]=> string(17) "C:\phpargtest.php" [1]=> string(6) "broken" [2]=> string(2) "-a" [3]=> string(1) "1" } array(0) { }