Skip to content

Instantly share code, notes, and snippets.

@ihsanberahim
Created November 15, 2013 03:41
Show Gist options
  • Save ihsanberahim/7478712 to your computer and use it in GitHub Desktop.
Save ihsanberahim/7478712 to your computer and use it in GitHub Desktop.
example of how static variable works
<?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