1

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 following define 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 line die(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.

1 Answer 1

1

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:

runkit_constant_redefine("HEADING_TITLE", 'Page 2');
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Joe, I'll do it the cleaner way then :)
No problem :-) Just pass a $title variable down or something. Constants are more for things like the company phone number that is displayed everywhere, or such things

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.