note 48862 deleted from features.commandline by cmb

From: Date: Sun, 18 Dec 2016 10:18:23 +0000
Subject: note 48862 deleted from features.commandline by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-208663@lists.php.net to get a copy of this message
Note Submitter: ken.gregg at rwre dot com ---- If you want to use named command line parameters in your script, the following code will parse command line parameters in the form of name=value and place them in the $_REQUEST super global array. cli_test.php <?php echo "argv[] = "; print_r($argv); // just to see what was passed in if ($argc > 0) { for ($i=1;$i < $argc;$i++) { parse_str($argv[$i],$tmp); $_REQUEST = array_merge($_REQUEST, $tmp); } } echo "\$_REQUEST = "; print_r($_REQUEST); ?> rwre:~/tmp$ /usr/local/bin/php cli_test.php foo=1 bar=2 third=a+value argv[] = Array ( [0] => t.php [1] => foo=1 [2] => bar=2 [3] => third=a+value ) $_REQUEST = Array ( [foo] => 1 [bar] => 2 [third] => a value )

« previous php.notes (#208663) next »