1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Instance

Discussion in 'Development' started by bySentixPE, May 28, 2018.

  1. bySentixPE

    bySentixPE Spider Jockey

    Messages:
    37
    How do I get the instance of my main class?
     
  2. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    From where?
    Why don't you just pass it around?
     
  3. byyEmirhanWSD

    byyEmirhanWSD Witch

    Messages:
    50
    GitHub:
    EmirhanWSD
    PHP:
    /** @var Main */
    private static $instance;

    public function 
    onLoad() {
      
    self::$instance $this;

    }

    /** @return Main */

    public static function getInstance(): Main {
      return 
    self::$instance;

    }
    on use,
    PHP:
    Main::getInstance()->
     
    OnTheVerge likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.