Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to refer config.php in class method?

Status
Not open for further replies.

alan123

MIS
Oct 17, 2002
149
0
0
US
I'm sure there's a simple answer to this problem - I have a class that relies on a bunch of vars that are set in a config.php file. I want to be able to use these variables inside my class methods without having to include the config file in every method. For example, I am currently doing this:
Code:
config.php:
<?php
$foo = 'bar';
?>

class.php:
<?php
class A{
include('config.php');
function print(){
echo $foo;
}
}
?>
In class.php, I cannot refer to the correct $foo value, anyone can help me? thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top