Questions about php Basics

Source: Internet
Author: User
Tags php basics
Php basic question a (aa)-& gt; B (bb)-& gt; c (cc); what does this mean? It is not too troublesome. can you give an example to illustrate it? I don't know much about this. here is more about basic php questions.
A ('A')-> B ('BB ')-> c ('CC ');
What does this mean?
It is not too troublesome. can you give an example to illustrate it?
Not familiar with this

Share: More


------ Solution --------------------
Obtain an object in function a, and then call Method B of this object. Method B returns an object, and then calls its c method through this object.
------ Solution --------------------

a()->b()->c();
function a() {
$r = new obj1;
return $r;
}
class obj1{
public function b(){
$r=new obj2;return $r
}
}
class obj2{
public function c(){
//do something
}
}

------ Solution --------------------
class T {
function b($v) {
echo $v;
return $this;
}
function c($v) {
echo $v;
return $this;
}
}
function a($v) {
echo $v;
return new T;
}

a('aa')->b('bb')->c('cc');

------ Solution --------------------
Reference:
A ('A')-> B ('BB ')-> c ('CC ');
What does this mean?
It is not too troublesome. can you give an example to illustrate it?
Not familiar with this

A () independent method returns an object of an instantiated class. this class contains function B. function B returns the object of another class and contains function c.

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.