I have a class called DatabaseController which I’ve set up as so:
<?php
class DBController {
public $dbName;
function _controller($passedDBName) {
$dbName = $passedDBName;
}
function dbConnect() {
print $this->$dbName;
}
} //end of class
?>
and I am calling it this way:
<?php
//make new database connection
$dbManager = new DBController("somevalue");
$dbManager->dbConnect();
?>
but I keep getting this error:
<b>Fatal error</b>: Cannot access empty property in
What am I doing wrong?
Thanks
In the constructor,
$dbName = $passedDBName;should be$this->dbName = $passedDBName;.Update:
$this->$dbNameshould be$this->dbName._controller()should be__construct().