|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2015-02-12 07:28 UTC] laruence@php.net
  [2015-02-12 13:24 UTC] fa@php.net
  [2015-02-14 14:36 UTC] laruence@php.net
 
-Status:      Open
+Status:      Closed
-Assigned To:
+Assigned To: laruence
  [2015-02-14 14:36 UTC] laruence@php.net
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 01:00:01 2025 UTC | 
Description: ------------ On our embedded system, we only build the php-cgi version to save space, /usr/bin/php is php-cgi. Note: This problem does not exist when calling php-cli via the command-line, only calling php-cgi via the command-line. When upgrading from PHP 5.3 to PHP 5.5, there seems to be some optimization that keeps $argv from being seen by 'getopt' unless $_SERVER['argv'] is referenced in the script. Interestingly $_SERVER['argv'] does not have to be executed to fix the behavior. In the test script below, uncommenting "var_dump($_SERVER['argv']);" allows 'getopt' to work. Test script: --------------- #!/usr/bin/php -qnC <?php echo "PHP Version: ".phpversion()."\n"; echo "register_argc_argv=".ini_get('register_argc_argv')."\n"; var_dump($argv); //var_dump($_SERVER['argv']); $opts = getopt("abc:"); var_dump($opts); ?> Expected result: ---------------- ./test-argv-getopt.php -ab -c4 PHP Version: 5.5.21 register_argc_argv=1 array(3) { [0]=> string(22) "./test-argv-getopt.php" [1]=> string(3) "-ab" [2]=> string(3) "-c4" } array(3) { ["a"]=> bool(false) ["b"]=> bool(false) ["c"]=> string(1) "4" } Actual result: -------------- ./test-argv-getopt.php -ab -c4 PHP Version: 5.5.21 register_argc_argv=1 array(3) { [0]=> string(22) "./test-argv-getopt.php" [1]=> string(3) "-ab" [2]=> string(3) "-c4" } bool(false)