PHP

Topic: Variables

what is the static variable in function useful for?

A static variable is defined within a function only the first time and its value can be modified during function calls as follows:	
<?php
function testFunction() { 
static $testVariable = 1;
echo $testVariable;
$testVariable++;
}

testFunction();  //1test
Function();  //2test
Function();  //3?>

Browse random answers: