A member variables Wich are a instance of an other class

liunx

Guest
Hello
I 've got a little question :

I have one class: food and an other : meal .

In my class food I 'd like to declare a member variables : meal1 wich are an instance of meal (meal meal1=new meal (); ).

The problem is that the 2 classes (food and meal ) are not in the same file so the meal's constructor is unknwon of food .

Is there anything that I cando except include (meal.class.php) ???

Thanks
Have a nice day
SEBWell that is the only way. If the class isnt included even if you made the class PHP isnt going to be able to find and and throw a Undefined Object at you.declare a global function __autoload($classname) { } with all the required code to load any class passed to it. then, when an unknown class is encountered, PHP will automatically call the function.
 
Back
Top