Hi All, I am new to PHP, I am trying to create an instance of class one in class2, but I am not able to complete it. Please if any of you people can help, it will be of great help. Below is the code. class DataAccessLayer { private $connect_mysqli; public function __construct() { include 'CustomException.class.php'; $this->DatabaseConnectionObject(); } private function DatabaseConnectionObject() { try { include 'Config.class.php'; $this->connect_mysqli = new mysqli($Config_HostName,$Config_UserName,$Config_Password,$Config_Database); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); } else { printf("Connect successful"); } } catch(customException $ex) { $ex->ProcessErrorMessage(); } } } -------------------------------------------------------------------------- class BusinessLayer { private $objDataAccessLayer; public function __construct() { //include 'CustomException.class.php'; $this->Initalize(); } private function Initalize() { include 'DataAccessLayer.class.php'; $this->$objDataAccessLayer = new DataAccessLayer(); print 'tester'; } } -------------------------------------------------------------------------- Next is my html page include 'BusinessLayer.class.php'; $newtest = new BusinessLayer(); -------------------------------------------------------------------------- It goes inside the line "$this->$objDataAccessLayer = new DataAccessLayer();" but it dosenot print the statement "print 'tester';". If you guys have some answers to this it is appreciated. Thanks
Try changing: $this->$objDataAccessLayer = new DataAccessLayer(); To: $this->objDataAccessLayer = new DataAccessLayer();