The issue is that you $mysqli is a function not a class. If you want
to reuse this function then it is worth making it into a class.
The call to $mysqli->XXXXX is a call to a class.
Search for object orientated programing in php, or OOP in PHP. This
will let you make the class that you are after.