Laravel 5 where the value of the->app is assigned $this

Source: Internet
Author: User

Why the property instances array is assigned in the instances method.
$this->app have a value.

Reply content:

Why the property instances array is assigned in the instances method.
$this->app have a value.

Or the morning brain sober, Container class looked at once found $this->app.
The Container class implements the Arrayaccess interface, and an introduction to the Arrayaccess interface can refer to the official documentation

Many Moden PHP frameworks now use this stuff.

The Offsetget method in the Container class is called by default when accessing $this->app, and then Offsetget calls the Make method of the Container class to get the type instance from Container based on the type passed in. The method. See the code for the Make method

if (isset($this->instances[$abstract])) {            return $this->instances[$abstract];        }

Instantly understand the source of $this->app ~

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.