Language Basics Php



Using the global Statement to Remember the Value of a Variable Between Function Calls


$num_of_calls = 0;
function andAnotherThing( $txt ){
    global $num_of_calls;
    $num_of_calls++;
    print "

$num_of_calls. $txt

";
}
andAnotherThing("A");
print("Called

");
andAnotherThing("B");
print("Called again

");
 ?>