| Newsgroups |
php.notes |
| Message-ID |
<[email protected]> |
While better than previously thanks to the rest_index parameter, be aware that the implementation follows the posix style, and is limited compared to what you might be used to with similar functionality in environments such as bash and python using argpase().
argv related variables are not modified, so the options remain and need to be skipped, and options cannot appear after positional parameters.
Thus after parsing with a spec of "Ex:"
-E -x foo bleh
bleh will appear at $argv[4], not $argv[1] as in typical modern implementations
and
-x foo bleh -E
would recognise -x but not -E, again unlike modern getopt implementations.
Rather than adding $rest_index, it's a shame that an option to use more flexible and friendly GNU style parsing to be consistent with other systems wasn't added instead, such as taking a $argv array by reference that was modified and enabled GNU behaviour.
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 94.101.154.134)
----
Manual Page -- https://php.net/manual/en/function.getopt.php
Edit -- https://main.php.net/note/edit/130534
Del: integrated -- https://main.php.net/note/delete/130534/integrated
Del: useless -- https://main.php.net/note/delete/130534/useless
Del: bad code -- https://main.php.net/note/delete/130534/bad+code
Del: spam -- https://main.php.net/note/delete/130534/spam
Del: non-english -- https://main.php.net/note/delete/130534/non-english
Del: in docs -- https://main.php.net/note/delete/130534/in+docs
Del: other reasons-- https://main.php.net/note/delete/130534
Reject -- https://main.php.net/note/reject/130534
Search -- https://main.php.net/manage/user-notes.php