|
PHP. Functions and scope of view, PART 3 |
Global variables: <?
$a = "pirmas "; $b = "antras";
function test1(){ global $a, $b; echo $a; echo $b; $b= $a . $b; }
test1(); echo "$b"; // It will print "pirmas antras"
?><?
$a = "cia a "; $b ="cia b ";
function test2(){ echo $GLOBALS["a"] . "<br>"; echo " {$GLOBALS["b"]}"; $GLOBALS["b"]= $GLOBALS["b"]. $GLOBALS["a"]; }
test2(); echo "$b";// It will print "cia a cia b"
?>
|