I was looking at the source for Drupal 7, and I found some things I hadn\'t seen before. I did some initial looking in the php manual, but it didn\'t explain these examples.
Inside a function, static
means that the variable will retain its value each time the function is called during the life of the page load.
Therefore in the example you've given, if you call a function twice, if it set $has_run
to true
, then the function would be able to know that it had previously been called because $has_run
would still be equal to true
when the function starts the second time.
The usage of the static
keyword in this context is explained in the PHP manual here: http://php.net/manual/en/language.variables.scope.php