note 129393 added to function.getopt

From: Date: Thu, 11 Apr 2024 05:32:19 +0000
Subject: note 129393 added to function.getopt
Groups: php.notes 
Request: Send a blank email to php-notes+get-221281@lists.php.net to get a copy of this message
Note that if you are mangling $argv separate from getopt(), that getopt() expects $argv to start with the command name in $argv[0]. So if you've shifted $argv, getopt() will start parsing at the second token, which means it will either miss the first option, or start parsing on the first option's value, breaking parsing. $cmd = array_shift($argv); $key_id=array_shift($argv); array_unshift($argv,""); $opts = getopt("a:b:c:"); getopt() skips over $argv[0] to start its parsing at $argv[1]. It doesn't really matter what is in $argv[0]. ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.13.131 (proxied: 24.16.159.68) ---- Manual Page -- https://php.net/manual/en/function.getopt.php Edit -- https://main.php.net/note/edit/129393 Del: integrated -- https://main.php.net/note/delete/129393/integrated Del: useless -- https://main.php.net/note/delete/129393/useless Del: bad code -- https://main.php.net/note/delete/129393/bad+code Del: spam -- https://main.php.net/note/delete/129393/spam Del: non-english -- https://main.php.net/note/delete/129393/non-english Del: in docs -- https://main.php.net/note/delete/129393/in+docs Del: other reasons-- https://main.php.net/note/delete/129393 Reject -- https://main.php.net/note/reject/129393 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221281) next »