My PhP files contain some long string constants and I'm trying to factor them out. So I created "my_string_constants.php" and used include
in header.php
. So far that works fine.
Now another file, page.php
also requires the string constants and header.php
. The scheme below tries to clarify these dependendies.
The string constants now seem available in my header only, not the rest of my page. I tried to resolve this by adding global ...
to each string constant in string_constants.php
. This resolved the error of "Unknown variable" but my string constants still seem unavailable to most of the page content.
What's the right way to get this working?
UPDATE
The issue's been solved. I should have used define(myString
instead of $myString = ...
. By doing so, I need just one include
in header.php
and the constants will be available to page.php
as well.
Thanks a million, you guys are great.