This PHP code is an example program that demonstrates how to write functions with static variables.
<?php // This is a function an internal static variable. function WithStaticVariables() { // Static variables are maintained across function calls. static $siValue = 5; echo "The now value is ".$siValue."<br />"; ++$siValue; } // Call the function three times. The value increases each time. WithStaticVariables(); WithStaticVariables(); WithStaticVariables(); ?>
© 20072024 XoaX.net LLC. All rights reserved.