Why I am not able to get the $somevar
on getVar()
I am getting this error while using print "Somevar is ". GLOBAL $somevar;
Line : 10 -- syntax error, unexpected 'GLOBAL' (T_GLOBAL)
and
E_NOTICE : type 8 -- Undefined variable: somevar -- at line 10
when using witout GLOBAL print "Somevar is ". $somevar;
<?php
$somevar;
function setVar() {
GLOBAL $somevar;
$somevar++;
}
function getVar() {
print "Somevar is ". GLOBAL $somevar;
}
setVar();
getVar();
?>