I have the following code and I can't explain why it outputs an error.
class User extends mysqli{
// property declaration
private $server;
private $user;
private $pass;
private $database;
private $conn;
function __construct($server, $user, $pass, $database){
$mysqli = new mysqli($server, $user, $pass, $database);
if ($mysqli->connect_errno) {
echo "Connect failed: ". $mysqli->connect_error;
exit();
}
$this->conn = $mysqli;
return 0;
}
function __destruct(){
$conn = $this->conn;
$conn->close();
}
}
and main code
include("global_config.php");
require "User.php";
$u = new User($con['server'],$con['user'],$con['pass'],$con['db']);
$u->query("SELECT * FROM users");
returns this error
Warning: mysqli::query() [mysqli.query]: Couldn't fetch User in E:\Xampp\htdocs\testphp\testMysql.php on line 9
normally, it should behave as here PHP inheritance, parent functions using child variables
but it doesn't
i've already exhausted my imagination thinking about most possible keywords I could use for a google search
any ideas?