jQuery mobile and PHP define variable
I'm really new with jQuery mobile but am loving working with it! I've come across a few problems regarding caching that I'm struggling with.
I have a php file with the followingdefine
in it:
define('HEADING_TITLE', 'Page 1');
That file is loaded on page 1 of the website. When I echo HEADING_TITLE, I see 'Page 1'.
Page 2 requires a different php file that overrides HEADING_TITLE as follows:
define('HEADING_TITLE', 'Page 2');
When I echo HEADING_TITLE, I still see 'Page 1'. I know the page 2 define is being processed because if I add the linedie(HEADING_TITLE);
immediately after the define, the script does indeed die but still shows me 'Page 1'!
How do I get jQuery mobile to allow me to overwrite the HEADING_TITLE variable? Or will I need to go about this another way? Creating different define variables like PAGE1_HEADING_TITLE and PAGE2_HEADING_TITLE is no problem, but if there's a better way I'd love to know it.
Answer
Solution:
Short answer is you can't override a define, they are called constants for a reason. Long answer is, you can in the runtime, but it's hacky and a bad idea.
If you choose to over-ride a constant in the runtime, do it like so: