$a = 1; $b = 2; function Sum(){     global $a, $b; // allows access to vars outside of function     $b = $a + $b; }   Sum(); echo $b; // output is 3

Read more of this post