Re: How to pass variables on php command line ?

From: Date: Fri, 23 Feb 2001 11:06:34 +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-41298@lists.php.net to get a copy of this message
I jsut found a solution working ;)) Thanks to your reply which helped me much. Here are two example files to see how it works : <? putenv("LANG=test"); $command=php -q test.php; echo $command; ?> which calls <? $lang=echo %LANG%; echo $lang; ?> It seems to work under Windows. Regards, Leonard Schneider --- Simon Garner <sgarner@expio.co.nz> wrote: > 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/ > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net > __________________________________________________ Do You Yahoo!? Yahoo! Auctions - Buy the things you want at great prices! http://auctions.yahoo.com/

« previous php.general (#41298) next »