#23859 [NEW]: getopts() indicates set options using FALSE

From: Date: Wed, 28 May 2003 15:45:07 +0000
Subject: #23859 [NEW]: getopts() indicates set options using FALSE
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-40590@lists.php.net to get a copy of this message
From: csnyder at chxo dot com Operating system: Linux / FreeBSD PHP version: 4.3.1 PHP Bug Type: Feature/Change Request Bug description: getopts() indicates set options using FALSE The current behavior of getopts() is counter-intuitive. From the manual: "If an option does not have an argument, the value will be set to FALSE." But this leads to a script like the following: #!/usr/local/bin/php <? $options = getopt("abcdef"); if ($options['e']===FALSE) print "I took e!"; ?> This is confusing -- we test for the presence of an option in the command line by checking whether it is FALSE? It would be quite helpful, at least in cases where no additional value was expected (an option string of "a" vs. an option string of "a:") for getopts to set the value to TRUE. The script above could then be: #!/usr/local/bin/php <? $options = getopt("abcdef"); if ($options['e']) print "I took e!"; ?> ...which is much easier to figure out. -- Edit bug report at http://bugs.php.net/?id=23859&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=23859&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=23859&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=23859&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=23859&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=23859&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=23859&r=support Expected behavior: http://bugs.php.net/fix.php?id=23859&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=23859&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=23859&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=23859&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23859&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=23859&r=dst IIS Stability: http://bugs.php.net/fix.php?id=23859&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=23859&r=gnused

« previous php.bugs (#40590) next »