1<?php
2 $myVariable = "a";
3 function changeVar($newVar) {
4 global $myVariable
5 $myVariable = "b";
6 }
7 echo $myVariable; // Should echo b
8?>
1$a = 1;
2$b = 2;
3function Sum(){
4 global $a, $b; // allows access to vars outside of function
5 $b = $a + $b;
6}
7
8Sum();
9echo $b; // output is 3