Log in

View Full Version : Help with variable scope


DRJ
02-27-2005, 07:13 AM
How can a make a variable retain its value


$myvar = 'some text';

require_once('./global.php');
require_once('./includes/functions_newpost.php');

Need $myvar to still have its value here, but it does not.

I can't put the require code first because it will mess with other variables. What I want to do is add on to a file and store some data to variables, require some other files I need, then use those variables.

Thanks

noppid
02-27-2005, 05:33 PM
How can a make a variable retain its value


$myvar = 'some text';

require_once('./global.php');
require_once('./includes/functions_newpost.php');

Need $myvar to still have its value here, but it does not.

I can't put the require code first because it will mess with other variables. What I want to do is add on to a file and store some data to variables, require some other files I need, then use those variables.

Thanks


Consider your VAR name a RESERVED word in vBulletin and change it's name. If it changes after the includes, you have chosen a variable name that exists in vbulletin therefore creating a conflict.

The fix is to change your variable name.

DRJ
02-28-2005, 01:05 PM
Thanks :)