MyBB Community Forums

Full Version: Making globals [SOLVED]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey everyone, I had an idea for a plugin, but I'm having trouble making it work.

I have a hook that gets run at the end of global.php, and what I need to do is create a global variable. This is where my problems start.

I've tried $GLOBALS['var'] = $content; but that doesn't want to work outside the function.

I've tried global $var; $var = $content; but that doesn't want to work outside the function either.

I can't declare $var outside the hook function because the plugin needs to run on all pages. Does anyone have any ideas to help me?

My only other option is to modify global.php to add my own variable to the end just before the $plugins->run_hooks("global_end"); but that doesn't seem like a good idea.

Edit: Wait, I've had a couple of ideas I want to try. This is what I get for not doing as much research as I could have...

Edit 2: Problem Solved! Cause: I should have used "global_start" instead of "global_end"...