PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
class SiteGenerate
{
function __construct()
{
}
function __destruct()
{
}
public function Initialise()
{
// Connect to database
$this->$m_database = new Database;
if(!$this->$m_database->Initialise())
{
$m_returncode = $m_database->GetReturnCode();
return false;
}
return true;
}
.....
private $m_database;
}
For some reason, although $m_database is defined as a member variable in the class (I do this so that I can access the instance of the database class outside of the scope of Initialise()) I keep getting the error
Fatal error: Cannot access empty property in C:\Apache\Apache2\htdocs\sitegen.php on line 129
where line 129 is the "$this->$m_database = new Database();" line. Why is this happening? I've tried moving $m_database above the constructors and destructors, but it doesn't seem to make any difference.
Last edited by mjseaden on Sat Feb 03, 2007 2:58 pm, edited 1 time in total.
The compiler seems to be getting through the rest of it okay, it seems to centralise around the definition of the member variable.
Could it be something to so with the fact that if I declare a member variable, it becomes a T_VARIABLE, but that it cannot be converted to an object when I try and set it equal to a new Class(); ?