·  PHP – Syntax – Variables – Scope – Static

 

- Info:

  - Static variable does not lose its value when the function exits and will still hold that value if the function is called again.

  - Variable is declared as static by placing the keyword STATIC in front of the variable name.

 

- Example:

  - Create PHP Console Application Test.php.

 

    Test.php

    <?php

   

      function keep_track() {

        STATIC $count  = 0;

        $count++;

        echo $count;

        echo "<br />";

      }

      

      keep_track();

      keep_track();

      keep_track();

        

    ?>