Re: Passing variables from script to script

From: Date: Wed, 11 Dec 2002 09:17:18 +0000
Subject: Re: Passing variables from script to script
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-127771@lists.php.net to get a copy of this message
On Tue, 10 Dec 2002, Stefan Hoelzner wrote: > Hi folks, > > surely this question has already been answered many times before in > this ng, but nevertheless: I want to pass variables from one .php to > another .php script. But I do not want to use either the > http://localhost/target.php?var1=test&var2=test2 nor the > POST method. > I would like to pass over general variables like usernames and > passwords for several MySQL-connects; obviously it is not a good way > to pass these vars via the mentioned ways. > > What else does PHP offer? Are there any other methods? Can I define > these vars as some kind of "global variables" in any ini-file? Use includes. http://www.php.net/include dbinfo.inc <?php $host = 'localhost'; $user = 'foo'; $pass = 'bar'; ... ?> showstuff.php <?php include 'dbinfo.inc'; if (!$conn = mysql_connect($host, $user, $pass)) { ... ?> Ideally this include will be outside the document root. If not, make sure it's not viewable or use a php extension such as .php See also the include_path php directive. Regards, Philip

« previous php.general (#127771) next »