QuoCAtted Text Here
Actually I'm passing connection Parameters by calling class Connection.Here what i cant understood is what is the way for passing the value in $link(which can declare as protected).when i want to use this connect class in other page how can i use this class.
<?php
class Connection
{
protected $link;
private $server, $username, $password, $db;
public function __construct($server, $username, $password, $db)
{
$this->server = $server;
$this->username = $username;
$this->password = $password;
$this->db = $db;
$this->connect();
}
private function connect()
{
$this->link = mysql_connect($this->server, $this->username, $this->password);
$result= mysql_select_db($this->db, $this->link) or die('sql error');
}
public function __sleep()
{
return array('server', 'username', 'password', 'db');
}
public function __wakeup()
{
$this->connect();
}
}
$link= new Connection('localhost','root','11222','1251');
?>