global var or passing a parameter in classes ?

From: Date: Wed, 05 Mar 2003 09:03:27 +0000
Subject: global var or passing a parameter in classes ?
Groups: php.general 
Request: Send a blank email to php-general+get-138245@lists.php.net to get a copy of this message
Hello, here is my problem : I have a class A and I instanciate this class at the beginninf of my script. I have another class B and in some functions of this class B, I need to access the instance of the class A. So in the functions of the class B, to access the class A, is it better to receive a reference of the class A in the contructor of the class B and then store the reference into a variable of the class B OR is it better to declare global $foo; at the beginning of the functions of the class B where I need to access the instance of the class A ($foo is the name of the instance of my class A) ??? Thanks a lot

« previous php.general (#138245) next »