PHP OOP Database Connection
![]() |
PHP OOP Database Connection |
In This Lesson we are going to learn how to create database connection in php oop concepts.Please copy and run the below codes to connect your database in php oop concepts..
Examples: Database Connection in php oop
<?php class Database{ private $host='localhost'; private $user='root'; private $pass=''; private $dbname='test'; public $link; //Generating Error Line public $error; public function connectDB(){ $this->link = new mysqli($this->host,$this->user,$this->pass,$this->dbname); if(!$this->link){ $this->error= "Connection Failed".$this->link->connect_error; }else{ echo "You Have Connected"; } } } $obj= new Database(); $obj->connectDB(); ?>I Hope You understand How to connect Database in PHP OOP..Please Leave your comment below and keep visiting for more codes..Thank You...
No comments:
Post a Comment
Thank You for Your Comment
Note: Only a member of this blog may post a comment.