I have a test database set up and I am trying to make a class to connect to it but I am having some pretty big problems.




class database {
    
    var    $server = "localhost";
    var    $db_user = "private"; // Enter your username
    var    $db_pass = "private"; // Enter your password
    var    $db_name = "private"; // Enter your database name
    
    function connect(){
    
        // Create connection
        $conn = new mysqli($server, $db_user, $db_pass, $db_name);
        
        if ($conn->connect_error) {
            echo "Not connected, error: " . $conn->connect_error;
        }
        else {
            echo "Connected.";
            return $conn;
        }
        
    }
$mysqli = new database;

In my index page, I have done this

$conn = $mysqli->connect();


now if I delete the database password from the class var, I still get "Connected" on my test page

I don't understand why the code isn't working.