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:
In class.php, I cannot refer to the correct $foo value, anyone can help me? thanks.
Code:
config.php:
<?php
$foo = 'bar';
?>
class.php:
<?php
class A{
include('config.php');
function print(){
echo $foo;
}
}
?>