MyBB Community Forums

Full Version: Predefined variable in plugin can't be used in functions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've set an array of values at the very start of my plugin file that I'd like to use in the plugin functions, however I can't use them. I'm definitely sure they've been set.

$var = array('test' => 'blah');

function pluginname_do_something() {
	global $var;
	
	echo $var['test'];
}

Why? pluginname_do_something() has been added to a hook and that's how it's called, so something to with that?
May sound crazy but try adding

global $var;

again before you define the array. I don't know why but I'm sure I had to do this in one of my plugins somewhere.
Wait what. I don't know why that would work, but okay. Thanks for the help Toungue