note 41862 added to function.getopt
| From: | chrisattinydotnet at rn2 dot php dot net | Date: | Fri, 23 Apr 2004 23:17:18 +0000 |
| Subject: | note 41862 added to function.getopt | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-68700@lists.php.net to get a copy of this message | ||
"phpnotes at kipu dot co dot uk" and "tim at digicol dot de" are both wrong or
misleading. Sean was correct. Quoted space-containing strings on the command line are one
argument. It has to do with how the shell handles the command line, more than PHP. PHP's
getopt() is modeled on and probably built upon the Unix/POSIX/C library getopt(3) which treats
strings as strings, and does not break them apart on white space.
Here's proof:
$ cat opt.php
#! /usr/local/bin/php
<?php
$options = getopt("f:");
print_r($options);
?>
$ opt.php -f a b c
Array
(
[f] => a
)
$ opt.php -f 'a b c'
Array
(
[f] => a b c
)
$ opt.php -f "a b c"
Array
(
[f] => a b c
)
$ opt.php -f a\ b\ c
Array
(
[f] => a b c
)
$
----
Manual Page -- http://www.php.net/manual/en/function.getopt.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+41862
Delete -- http://master.php.net/manage/user-notes.php?action=delete+41862&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+41862&report=yes
Search -- http://master.php.net/manage/user-notes.php