How to instantiate a new instance of a "global" class?

  constructor, global-variables, php

Came across a weird constructor of a class defined in the / namespace. It doesn’t let you re-instantiate more than one instance of it.

private $init = false;
public function __construct()
{
    if (self::$init) {
        return;
    }
    self::$init = true;
}

Is it possible to instantiate a new copy of this class after a it’s instantiated once? I realize I can extend this class and overwrite the child’s constructor, but looking to see if there’s a way to get around this early return without extending it.

Source: Ask PHP

LEAVE A COMMENT