How can this sentence be understood?

Source: Internet
Author: User
How can this sentence be understood?
Model('seo')->type('index')->show();

Finally translate


Reply to discussion (solution)

Model ('SEO ') gets an seo object
-> Type ('index') executes the type method of the seo object
-> Show (); execute the show method of the seo object

Model ('SEO ') gets an seo object
-> Type ('index') executes the type method of the seo object
-> Show (); execute the show method of the seo object



My question is, why do I use two arrows? is that compliant with the syntax? because I understand Model ('SEO ')-> type ('index ')
It is a method called after the object is instantiated, and it calls another method later, but Model ('SEO ')-> type ('index ')
It's not an object at this time. how can this problem be solved?

If arrows can be used consecutively, there are many methods in a class. do you mean you can use a long string of arrows to call them?


Model ('SEO ') gets an seo object
-> Type ('index') executes the type method of the seo object
-> Show (); execute the show method of the seo object



My question is, why do I use two arrows? is that compliant with the syntax? because I understand Model ('SEO ')-> type ('index ')
It is a method called after the object is instantiated, and it calls another method later, but Model ('SEO ')-> type ('index ')
It's not an object at this time. how can this problem be solved?



The called method returns $ this for cascade.

class  Orange{    public function a(){        echo "a";        return $this;    }    public function b(){        echo "b";        return $this;    }    public function c(){        echo "c";        return $this;    }}$orange = new Orange();$orange->a()->c()->b();


acb

As long as these functions (methods) return objects, you can use this continuous operation method.

But Model ('SEO ')-> type ('index') is not an object at this time.
How do you know that he is not an object?

Suddenly understood! In the past, the concatenation principle in javascript was used.

Suddenly understood! In the past, the concatenation principle in javascript was used.


However, javascript uses vertices instead of arrows.

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.