Search code examples
phpcs-cart

PHP what does this means App::instance()->init($_REQUEST)?


my run.php file contains

use Installer\App;

include 'app/Installer/App.php';
App::instance()->init($_REQUEST);

And app.php contains two function instance() and init($param = array()).

Why a function is called by another function??


Solution

  • App::instance() - it's just call to static class method named 'instance' (it's seems like use of Singleton pattern, so i suppose it returns some instance of 'App' class).

    init($_REQUEST) - is a call to an instance method of class of object that returned by instance() method.

    You can split this calls to different code lines for better understanding:

    $instance = App::instance();
    $instance->init($_REQUEST);
    

    It's not a "function called by another function", it's just little piece of object-oriented programming.