Digital World Freelancer

The Digital World Freelancer group is applying latest Technologies Like HTML, CSS, CSS3, JavaScript, JQuery, PHP and more...... for website designing & developing... reach at our organization http://www.digitalworldfreelancer.com

Facebook Page

Friday, September 11, 2015

Database Connection in PHP and Mysqli with OOPs concept

<?php
class Connect{
public $hostname = 'localhost';
public $username = 'root';
public $password = '';
public $database = 'test';
public $db;
public function conn(){
$db = new mysqli($this->hostname, $this->username, $this->password, $this->database);
if($db->connect_errno){
echo "database connection error found";
}else
                                               {
echo "database connect successfully!";
}
}
}

$conn = new Connect();
$conn->conn();
   
?>

Output: database connect successfully!

No comments: