14 Static variable in PHP

Program:
<?php

function display()
{
    static $a = 10;
    $b = 20;
    echo "Static A= $a<br/>";
    echo "Non-Static B= $b <br/>";
    $a++;
}

display();
display();
display();
display();

?>


Output:

Static variable in PHP

Previous
Next Post »