Re: keeping track of the right instance od a class ?
| From: | Alan Knowles | Date: | Fri, 03 Jan 2003 08:30:11 +0000 |
| Subject: | Re: keeping track of the right instance od a class ? | ||
| References: | 1 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-2823@lists.php.net to get a copy of this message | ||
firepage wrote:
Hi, sorry about the subject but I dont know how to explain...
I have a class A that calls a function in class B, this function returns a value to a function of class A
that all works in that a value is returned , but not I think to the same instance... ?
whatever is going on I cant do this $this->value=$value; with the returned value.
I assume I need to be sending a reference to this instance of class A ?
class A {
var $value;
function A (){
$this->value='';
$b=&new B();
$b->get_value('A_callback',$this);/*I tried &$this*/
echo $this->value;
}
function A_callback($value){ $this->value=$value;
/*$value exists and is returned as expected if I echo $value*/
/* but $this->value; ($a->value;) is NOT being set*/
}
}
class B{
function B(){
}
function get_value( $callback , $obj ){
..........................................&$obj
$value="I want this returned"; $obj->$callback($value); /*this is successfully calling $a->A_callback("I want this returned");*/ } } $a=&new A; I tried returning the object from class B but with the same results. Any pointers appreciated ! Regards, Simon Wheeler firepages-- Can you help out? Need Consulting Services or Know of a Job? http://www.akbkhome.com