note 18557 added to language.references.return
| From: | ap at jelgava dot lv | Date: | Mon, 28 Jan 2002 01:02:18 +0000 |
| Subject: | note 18557 added to language.references.return | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-25881@lists.php.net to get a copy of this message | ||
<?
// Refrence by function: HOW ?
class A
{
var $ca = "A class variable";
function getvar(){return $this->ca;}
}
class B
{
var $ca = "B class variable";
function getvar(){return $this->ca;}
}
class FunctionRefrence
{
var $classrefr;
function &FunctionRefrence()
{
$this->classrefr[0] = & New A;
$this->classrefr[1] = & New B;
}
function getrefr($refrid){return $this->classrefr[$refrid];}
}
// ====================================================
$MyObj = New FunctionRefrence;
// we can do that:
$tmp = $MyObj->getrefr(0);
echo $tmp->getvar()."<BR>";
$tmp = $MyObj->getrefr(1);
echo $tmp->getvar();
// also can:
echo $MyObj->classrefr[0]->getvar();
// ++++++++++++++++++++++++++++++++
// but HOW do that or likewise (one row with argument processing)
$MyObj->getrefr(0)->getvar();
?>
--
http://www.php.net/manual/en/language.references.return.php
http://master.php.net/manage/user-notes.php?action=edit+18557
http://master.php.net/manage/user-notes.php?action=delete+18557
http://master.php.net/manage/user-notes.php?action=reject+18557