Doc #81352 [NEW]: Doc states getopt returns false when it really returns an empty array
From: edg at greenberg dot org
Operating system: Centos 7
PHP version: 7.4.22
Package: Documentation problem
Bug Type: Documentation Problem
Bug description:Doc states getopt returns false when it really returns an empty array
Description:
------------
---
From manual page: https://php.net/function.getopt
---
ON the manual page for getopt it states:
> This function will return an array of option / argument pairs, or
false on failure.
When there are no options, it returns an empty array.
So my bug report is to suggest that you indicate that "false on failure"
refers to some other kind of failure and that no options found is
indicated by an empty array.
Thanks
Test script:
---------------
$options = getopt('', ['help', 'limit:', 'loops:',
'endtime:',
'tomorrow', 'agency:']);
Expected result:
----------------
Based on the doc, if I call the script with no options, I expected
failure.
Actual result:
--------------
I got an empty array.
Note that I'm quite happy with the empty array, but wish that things in
the doc had been a bit less ambiguous.
--
Edit bug report at https://bugs.php.net/bug.php?id=81352&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=81352&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=81352&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=81352&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=81352&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=81352&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=81352&r=support
Expected behavior: https://bugs.php.net/fix.php?id=81352&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=81352&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=81352&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=81352&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81352&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=81352&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=81352&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=81352&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=81352&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=81352&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=81352&r=mysqlcfg
Thread (3 messages)
- edg at greenberg dot org