connection global across functions without using global
That's because one of the entire reasons mysql_ functions went the way of the dodo and that both mysqli and PDO make objects is that it's NOT SUPPOSED TO BE GLOBAL.
It's also where object scope is handy as you can pass it to the constructor of the things that should have access.
Scope isolation is a good practice, it can be a hair more code but it maintains the separations needed to have a degree of ring security in the shit-shows that are interpreted languages.
Just like how global variables should be kept to a bare minimum and never used for anything security related.
Thus why the idiots putting sql un/pass into DEFINE are complete morons.