note 31964 added to ref.classobj
| From: | ninja at rack1 dot php dot net | Date: | Sat, 10 May 2003 16:37:05 +0000 |
| Subject: | note 31964 added to ref.classobj | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-47819@lists.php.net to get a copy of this message | ||
the best way i found to call an instance of a class from within another class is like so:
class foo {
var $meta = 1;
}
class bar {
var $foo;
function bar(&$objref) //constructor
{
$this->foo =& $objref;
}
function doohickey()
{
return $this->foo->meta;
}
}
$fooclass = new foo();
$barclass = new bar($fooclass);
echo $barclass->doohickey();
--
http://www.php.net/manual/en/ref.classobj.php
http://master.php.net/manage/user-notes.php?action=edit+31964
http://master.php.net/manage/user-notes.php?action=delete+31964
http://master.php.net/manage/user-notes.php?action=reject+31964