Jump to content

Making variables available everywhere


scrubbicus

Recommended Posts

What's the best way to make variables global so that absolutely everything can access it? Right now I currently have my variables files required on index.php so that every file can access it but I'm trying to access some of those variables from within my classes and they can't find those variables. I've also tried requiring onload off my main initialize class that variables file but then anywhere I call that variable outside a class it can't find it.

Link to comment
https://forums.phpfreaks.com/topic/158989-making-variables-available-everywhere/
Share on other sites

I'm slowly getting the hang of OOP but I think I'm still using the entirety of it wrong. Currently I'm making everything in one huge giant class and defining all the definite private variables in that class the I can use them throughout. My construct for that class is the MySQL connect and MySQL select db and I call this class at the beginning of index.php. $initialize = new initAll(); then I just make all my functions and variables in that class through the script I feel like I'm definitely not using OOP correctly and capitalizing on parent/child relationships which I haven't really gotten to yet because when I do it becomes a hassle for me to call functions and variables from different children, from the parent, or from classes entirely different.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.