Re: How to pass variables on php command line ?

From: Date: Fri, 23 Feb 2001 10:11:39 +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-41294@lists.php.net to get a copy of this message
From: "Leonard Schneider" <leonardschneider@yahoo.com> > Thanks for your reply > > Maybe it is dut to that I use a Windows98 OS, but environment variables > functions don't seem to work. Moreover, I couldn't make the exec() and > system() commands properly to run php from dos shell. Is it a security > ? > Anyway as my first problem is that > is there any trick to pass variables to php script when executing from > command line ? > Is there anyone who would have any idea or trick to help this ? > > Leonard Schneider > Ah, I'm afraid I have no experience with PHP under Windows so I can't really help you there sorry. I'm not aware of any other way than environment variables to pass data to PHP scripts executed from the command line so you may be out of luck if they don't work under Windows. Perhaps someone else on this list will be able to help... Cheers Simon Garner > --- Simon Garner <sgarner@expio.co.nz> wrote: > > 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 > > > > > __________________________________________________ > Do You Yahoo!? > Yahoo! Auctions - Buy the things you want at great prices! http://auctions.yahoo.com/

« previous php.general (#41294) next »