Hi,
On 16 Jul 2004 14:03:06 -0700,
de********@seznam.cz (Radim B) wrote:
Hi,
I need to share 1 object e.g. "UserPermission" to 2 others e.g.
"Document", "File" objects.
How can I make it without pointers? Many thanks for any help.
I nearly always use a mediator:
class mediator{
function &obj_instance(){
static $instance;
if (!isset($instance)){
$instance = new obj();
}
return $instance;
}
}
You can access this in any (class) function with
$obj =& mediator::obj_instance();
In this version all $obj would use the same object, but you can
control that from within the mediator.
HTH, Jochen
--
Jochen Daum - Cabletalk Group Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/