Re: Variable problem with a function calling a ext. librairy

From: Date: Fri, 22 Feb 2002 01:31:14 +0000
Subject: Re: Variable problem with a function calling a ext. librairy
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-85798@lists.php.net to get a copy of this message
In article <20020221143842.81198.qmail@pb1.pair.com>, map@inter-resa.com says... > Hello, > > I created a librairy with configuration setting: background color, font size, > customer's name, etc. Like this: > (lib_config.inc) > > $bgcolor = "#ffffff"; > $co = "ABC enterprise"; > > A second file is building html page headders: > (lib_intra.inc) > > function title($name_section,$name_page){ > print "<br><br>\n"; > print font_titre3."$co</font><br><br>\n"; > print font_titre2."$name_section</font><br>\n"; > print font_titre2."$name_page</font>\n"; > print "<br><br>\n"; > } > > Finnaly, I call the title function in a web page to dynamicly create the code: > (test.php) > > echo title("General presentation","The annual report"); > > My problem (you guessed it!) is that the file lib_intra.inc is beeing processed > by php (when callled by my web page test.php) and the 2 variables are sent ok > but NOT the $co wich is in the 1st file (lib_config.inc). Of course my > lib_intra.inc has a: require ("lib_config.inc"); > > Because I dont want to duplicate infos that are used in many files, the > lib_config.inc is important and must be called to supply the data I need. > > How can I set this so all the variables will be process under php? > > Thanks to all! > You are trying to access the value of $co in a function; you'll need to declare it as a global value within the function or pass it to the function as a parameter. -- David Robley Temporary Kiwi!

« previous php.general (#85798) next »