03-04-2018, 05:56 PM
Functions are sort of like standalone programs. If you want them to have access to things outside them, you usually have to bring it inside the scope of the function. That means instantiating the class, calling the function, or using a global. For instance... Iirc, you can do global $db; to use the db class that was already instantiated in the header. This can get weird if you reuse that variable name somewhere else on the page.