Avoid object twice

From: Date: Mon, 02 Jun 2008 13:00:59 +0000
Subject: Avoid object twice
Groups: php.general 
Request: Send a blank email to php-general+get-274920@lists.php.net to get a copy of this message
Please take a look at code. --------a.php-------- $obj=new my("Hello"); $obj->buff(); Class my{ private $word; function __construct($getword){ $this->word=$getword; } public function buff(){ echo $this->word."<br />"; } -------------------------------------- -----b.php----------------------- function __autoload($class_name) { include_once $class_name . '.php'; } $objref=new my("Good"); $objref->buff(); -------------------------------------------- I get an Echo; Good Hello Hello I do not need to get Hello twice. When I b.php , $obj=new my("Hello") is loaded. Do you have any adia to avoid load $obj in a.php twice? Regards, Yui

« previous php.general (#274920) next »