Php mysql connection class with oop
<?php class dbConnect { var $host; var $username; var $password; var $database; function __construct($host,$username,$password,$database) { $this->host=$host; $this->username=$username; $this->password=$password; $this->database=$database; $this->connection(); } function connection() { $conn=mysqli_connect($this->host,$this->username,$this->password,$this->database); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } else echo "connected"; mysqli_close($conn); } } $log=new dbConnect("localhost","root","","login"); ?>