PHP: static variable outside of class

Viewed 2722

I have seen in 3rd party code a variable declared as static, but outside of any class, simply in a "normal" function.

<?php
function doStuff(){
    static $something = null;
}
?>

I have never seen static used this way, and I cannot find anything it in the PHP documentation.

Is this legal PHP code? Is this effectively the same as a global variable? If not, what is the purpose?

1 Answers
Related