Created
November 15, 2013 03:41
-
-
Save ihsanberahim/7478712 to your computer and use it in GitHub Desktop.
example of how static variable works
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function repeatIt(){ | |
static $id; | |
if(!$id) $id=0; | |
$id++; | |
echo sprintf('<div id="someprefix_%s">Butang %s</div>',$id,$id); | |
} | |
for($i=0;$i<10;$i++){ | |
repeatIt(); | |
} | |
return; //just exit but i don't want halt the script execution |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment