oop-php there is a paragraph writing do not understand the meaning, ask for advice

Source: Internet
Author: User
Today look at Laravel framework code there's a piece of code in a class

public function isLocal(){    return $this['env'] == 'local';}

I've never seen anything like it. $this['env']

Reply content:

Today look at Laravel framework code there's a piece of code in a class

public function isLocal(){    return $this['env'] == 'local';}

I've never seen anything like it. $this['env']

The application class inherits the container class container class and implements the Arrayaccess,
So the example of container is to support array-type access: $object [' key '];
Implementation of array-type access in Container: https://github.com/laravel/framework/blob/4.2/src/Illuminate/Container/Container.php#L814 line to the end
PHP array-type access interface: http://php.net/manual/zh/class.arrayaccess.php

@ Ang Sul solution for you = HTTP://WENDA.GOLARAVEL.COM/QUESTION/5

Is there a method called __get , for example:

public function __get($key) {    return $this->var[$key];}

This is the implementation of the PHP class collection specifically see demo http://blog.sina.com.cn/s/blog_7550abf30101ajda.html

  • 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.