in my php i call database connection from other php but i got confuse here its not echo current php echo
this my db.php code
<?php
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
class Database {
private $con;
public function connect (){
include_once("constant.php");
$this->con = new Mysqli(HOST,USER,PASS,DB);
if ($this->con->connect_error) {
echo"connect fails";
//return $this->con;
}else{echo "connection success";}
//return "DATABASE_CONNECTION_FAIL";
}
}
$db = new Database();
$db->connect();
?>
and this my user.php code
<?php
/**
* user class for account creation and login purpose
*/
class User {
private $con;
function __construct(){
include_once("../database/db.php");
$db = new Database();
$this->con = $db->connect();
if($this->con) {
echo "connect databases";
}
}
}
$obj = new User();
?>
in my browser i call user.php but i got echo as connection success connection success
its repeat 2 time but in user.php echo not display
my expect echo is connect databases