I have some pages that share a common variable. At first, I just copied $max = 196;
into each page to update it. This is obviously a bad way to do it as it's a lot more work and it's easy to make a mistake. I want to change it so I can change the value of this variable in a single place and everywhere use this value.
Right now, I put include 'rises.php';
on every page instead of the actual variable, and the contents of rises.php is <?php $max=196; ?>
I have also tried...
- Saving
196
to a .txt file and each page opening it using `fopen(). - Creating a small MySQL table which holds only this variable name and it's value.
So my question is...
What's the best way of managing a variable where multiple pages need to use it? In my case it's only 5-6 pages, but each page loads it a ton of times.