I have problem passing mysqli to my class. It works fine when it's passing to non-class. I tried to use Dependency injection here but for some reason it won't show results when printed, it's just a blank page.
Here is my connect.php
<?php
$db = new mysqli('localhost', 'root', '', 'audiologiska_kliniken');
if($db->connect_errno > 0){
die('Ett fel inträffade [' . $db->connect_error . ']');
}
My test class:
<?php
//error_reporting(0);
include '../include/connect.php';
class test
{
private $mysqli;
function __construct(mysqli $db)
{
$this->mysqli = $db;
$this->testing();
}
function testing()
{
$result = $this->mysqli->query("Select * from person");
print_r($result);
}
}