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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.