I implemented a class like this:
class ClassRoom
{
public $desired_connection; // variable of type DesiredConnection
//Constructor
public function __contruct()
{
$this->desired_connection = new DesiredConnection(); //Initialize
}
public function save(){
//Save Desired Connection
$this->desired_connection->saveDesiredConnection();
}
}
Upon calling $classroom->save(), runtime does not recognize $this->desired_connection as DesiredConnection object and throws this error:
"Call to a member function save() on a non-object."
When I output, gettype($classroom->desired_connection), it outputs NULL.
Any suggestions on what I may be doing wrong here ?