Php chained call if the method is called immediately after the new object

Source: Internet
Author: User
After checking on the internet, php needs to encode its own code to implement the chain, and it seems that it can only be a method and then call the method. However, what I want to implement is a chain like this. After the new entity is added, the method is called: {code ...} it seems that it cannot be implemented, even if return $ this in the constructor,... after checking on the internet, php needs to encode its own code to implement the chain, and it seems that it can only be a method and then call the method.
But what I want to implement is a chain like this. It is the method to call after the new object is created:

New MyClass ()-> setData ('1 ');

It seems that it cannot be implemented, even in the constructorReturn $ thisBut the IDE still prompts errors.

Reply content:

After checking on the internet, php needs to encode its own code to implement the chain, and it seems that it can only be a method and then call the method.
But what I want to implement is a chain like this. It is the method to call after the new object is created:

New MyClass ()-> setData ('1 ');

It seems that it cannot be implemented, even in the constructorReturn $ thisBut the IDE still prompts errors.

(New MyClass ()-> setData ('1 ');

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.