You're not really displaying an understanding of variable scope. You should avoid trying to global scope variables and connection pointers. You also don't seem to understand how classes work. You know you can use mysqli as an object itself?

When you call a new instance of a class, the object will call the construct() magic method. I would use this to connect to the database, or at least set the connection parameters (although an immediate connection avoids actually storing the values). I would then store the connection pointer in a property of the class. The class should also store methods to act on the connection.

Classes and objects are used to handle specific areas - separating logic into classes that deal with similar tasks. Therefore, a database class should be built to contain all the tools to access the database.