calling global variables into a function in header.php
-
I was having trouble trying to call global variables into a function I’ve put in my modified header, so I tried using a simple function in the default header.php and I’m still having the same problem that the global variables just don’t seem to work in the funtion:
<?php
$a = 1;
$b = 2;
function Sum() {
global $a, $b;
$b = $a + $b;
}Sum();
echo 'b value is:'.$b;
?>When in an empty php page this function outputs $b=3, but in header.php $b=2.
Does anyone know why? Any help would be greatly appreciated.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘calling global variables into a function in header.php’ is closed to new replies.