Problems using globals
Posted: Wed Sep 21, 2005 5:49 pm
Because I can't seem to get globals to work within functions, I've created the simplest function for testing:
If I save that as an include file (glenn.function.php) and go right to it with my browser I get:
Number: 2
But if I try to include that file into a template (require_once) or try creating a user defined tag and inserting it I get:
Number:
Of course using the function without the global works:
The global doesn't work. So how do I get globals to work in CMSMS?
Thanks!
Code: Select all
$num = "2";
function glenn() {
global $num;
echo "Number: ".$num;
}
glenn();Number: 2
But if I try to include that file into a template (require_once) or try creating a user defined tag and inserting it I get:
Number:
Of course using the function without the global works:
Code: Select all
function glenn() {
$num = "2";
echo "Number: ".$num;
}
glenn();Thanks!