hi all..
I just want to ask,is it correct,in a class that we have built,PHP will first execute the constructor function before the others??
to make it clear is this is example :
<?php
class database {
public function __construct() {
$this->open_connection();
}
public $connection;
public function open_connection() {
$this->connection= mysql_connect("localhost","root","mypassword");
if(!$this->connection) {
die ("connetion failed: " . mysql_error());
}
public function close_connection() {
$connection=mysql_close($this->connection);
}
}
$database=new database();
?>
is it because of the PHP will execute the constructor function first,then i cannot write this code ? :
public function __construct () {
$this->$sonnection;
}
please help..
Thank You :)