Re: How to pass variables on php command line ?

From: Date: Fri, 23 Feb 2001 07:18:10 +0000
Subject: Re: How to pass variables on php command line ?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-41281@lists.php.net to get a copy of this message
From: "Leonard Schneider" <leonardschneider@yahoo.com> > I use PHP as script to generate HTML pages using the command > php -q script.php > file.html > > I would like to pass some variables to the PHP script so that it > generates a different HTML file. > I tried the -d option but it seems it doesn't work. > Is there any means of doing this ? > > > Leonard Schneider > Easiest way is using environment variables. <?php system("SOME_VAR=blah; php -q script.php > file.html"); ?> Then in script.php you can do: <?php $some_var = getenv("SOME_VAR"); ?> Hope this helps, Simon Garner

« previous php.general (#41281) next »