I have a php file:
<?php
$a = 1;
function test(){
echo $a;
}
test();
?>
And I get this error:
Notice: Undefined variable: a in X:\...\test.php on line 4
Using XAMPP @ 32bit W7.
I have a php file:
<?php
$a = 1;
function test(){
echo $a;
}
test();
?>
And I get this error:
Notice: Undefined variable: a in X:\...\test.php on line 4
Using XAMPP @ 32bit W7.
You have trouble understanding variable scope. $a is defined in the global scope, but not in the function scope. If you want your function to know what $a contains, you have two choices :