keeping track of the right instance od a class ?
| From: | firepage | Date: | Fri, 03 Jan 2003 07:57:10 +0000 |
| Subject: | keeping track of the right instance od a class ? | ||
| Groups: | php.gtk.general | ||
| Request: | Send a blank email to php-gtk-general+get-2822@lists.php.net to get a copy of this message | ||
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 ){
$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