MikeBronner
Programmer
I must be having a brain-fart or something. Something I know I have done in the past is giving me problems today and I can't get my head around it. (Must be one of those days ...)
Here's my situation: I want to pass the instance of a class (my db abstraction class) into another class, like so:
Now, in myClass I consume it like so:
In the set-method it gives me the following error:
I'm stumped! Anyone know a way out? Oh, and if I do this in PHP 5.2.0 it returns the new error:
Take Care,
Mike
Here's my situation: I want to pass the instance of a class (my db abstraction class) into another class, like so:
Code:
$myClass->set_database($r_database);
Now, in myClass I consume it like so:
Code:
class myClass
{
private $r_db = null;
[...]
public function set_database($r_db)
{
$this->$r_db = $r_db;
}
[...]
}
In the set-method it gives me the following error:
Where line 38 isPHP Notice: Object of class Database to string conversion in myClass.php on line 38
Code:
$this->$r_db = $r_db;
I'm stumped! Anyone know a way out? Oh, and if I do this in PHP 5.2.0 it returns the new error:
PHP Catchable fatal error: Object of class Database could not be converted to string in myClass.php on line 38
Take Care,
Mike