Laravel - How to statically call non-static methods in PHP?
黄舟
黄舟 2017-07-05 10:02:01
0
1
950

Static call in larave project

facade

The title method in the Admin class is non-static

How is this achieved?

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all (1)
学习ing

In the final analysis, it is achieved through themagic method __callStatic

IlluminateSupportFacadesFacadeCode at the bottom

https://github.com/illuminate...

/** * Handle dynamic, static calls to the object. * * @param string $method * @param array $args * @return mixed * * @throws \RuntimeException */ public static function __callStatic($method, $args) { $instance = static::getFacadeRoot(); if (! $instance) { throw new RuntimeException('A facade root has not been set.'); } return $instance->$method(...$args); }

AboutFacadeis one of the more important features ofLavavel. You can learn more about its implementation.

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!