RE: [PHP] Passing args to a PHP script from the command line
| From: | Thijs Lensselink | Date: | Thu, 10 Jun 2004 11:37:16 +0000 |
| Subject: | RE: [PHP] Passing args to a PHP script from the command line | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-188026@lists.php.net to get a copy of this message | ||
Phil Ewington - 43 Plc wrote on donderdag 10 juni 2004 12:58:
> Hi All,
>
> Can anyone tell me how to pass arguments to a PHP script from the
> command line? I know I need to use the -args option but how exactly,
> I have tried the following...
>
> /usr/bin/php myscript.php -args key=value
You don't have to call the -args argument. just run the script
from command line like this:
php myscript.php value
Where value is the argument you want to use in the script.
These arguments are stored in an arrray ($argv).
Do a print_r($argv) and you can see the content.
>
> but this does not work, the script executes but key is not available
> as $_GET["key"] in my script. Any pointers will be much appreciated.
>
> TIA
>
> Phil.
>
> ---
> Phil Ewington - Technical Director
>
> 43 Plc - Ashdale House
> 35 Broad Street, Wokingham
> Berkshire RG40 1AU
>
> T: +44 (0)1189 789 500
> F: +44 (0)1189 784 994
> E: mailto:phil.ewington@43plc.com
> W: www.soyouthink.com
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004