<?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!
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:
Post a Comment