Q:

Checking if a static variable is Null after setting it to null

Recently, when I was downloading an OpenSource project, I came accross this PHP code:
<?php

namespace That\Thing;

final class Somewhere
{
  //...

  public static function somefunc( /*...*/ )
  {
    static $exists = null;
    if ($exists === null) {
      $exists = \function_exists('mb_substr');
    }

    if ($exists) {
      //...

My PHP is OK, so reading the above, it puzzled me what static $exists = null precisely does? It did not make sense to me to set a variable to Null, then immediately check if the variable is actually Null? (Add Duhh here)
Is there some sort of PHP version checking going on here? Why would someone write this code?
I have included the surrounding OOP, in case it has an influence. Can someone explain this?

A:

static persists the variable value across function calls. But, static variables can only be initialised with constant values. This is not supported (function call in static initialiser):
static $exists = \function_exists('mb_substr');

So as a workaround for this the variable is initialised to null, then if the value is null (if it's the first time the variable is accessed, right after initialisation), it's set to its actual value.

static values are initialised in the compilation stage, before runtime. Hence no runtime function can be called or other overly complex runtime calculation can be done at that time. static $exists = null happens at compile time; then the first time the function is called, a runtime calculation is done.

