note 1931 modified in language.variables.external by irc-html

From: Date: Sat, 19 Jan 2002 19:00:06 +0000
Subject: note 1931 modified in language.variables.external by irc-html
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-25215@lists.php.net to get a copy of this message
Concerning parameters on the command-line: If you are trying to run a php-script as a shell command, you can add this function to your code to get access to the parameters on the command-line: function get_commandline() { global $argc, $argv; for ($i=0; $i<$argc; $i++) { $my_args = array(); if (ereg("(.*)=(.*)", $argv[$i], $my_args)) { $GLOBALS[$my_args[1]] = $my_args[2]; } } } This parses the all the given parameters in a call like "test.php arg1=abc arg2=def" into variables in the global scope, named as the arguments were ($arg1 is set now to "abc"). --was-- Concerning parameters on the command-line: If you are trying to run a php-script as a shell command, you can add this function to your code to get access to the parameters on the command-line: <PRE>function get_commandline() { global $argc, $argv; for ($i=0; $i<$argc; $i++) { $my_args = array(); if (ereg("(.*)=(.*)", $argv[$i], $my_args)) { $GLOBALS[$my_args[1]] = $my_args[2]; } } }</PRE> This parses the all the given parameters in a call like "test.php arg1=abc arg2=def" into variables in the global scope, named as the arguments were ($arg1 is set now to "abc"). http://www.php.net/manual/en/language.variables.external.php

« previous php.notes (#25215) next »