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.