Using a global variable
-
I want to add a gloabal variable once and then reference it on many pages. The value will change once a year so I would like to only have to update one file for it to automatically update all the pages.
I am new at this. Can someone tell me if this will work or if there is an easier or better way?
In my page.php file add:
<?php global $CurrentYear = 'dog'; ?>
Then on any page I can add:
<?php echo 'This is the year of the ' . $CurrentYear; ?>
Thank you!
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Using a global variable’ is closed to new replies.