Why can't return be used in php constructor?

Source: Internet
Author: User
RT hopes to expand this knowledge point and ask experts for answers or give an entry to the information ~ RT
I hope to expand this knowledge point, ask experts for answers or give an entry to a document ~

Reply content:

RT
I hope to expand this knowledge point, ask experts for answers or give an entry to a document ~

You can try it out. Why do you want to send it.
A constructor is a special function that does not return values. It does not execute any function even if return is added.

Who do you want to return the result?

Not only php, but constructors of all object-oriented languages do not return.

The purpose of the constructor is to return an instance of the class.
You can imagine that a programming language does not support Object-Oriented Programming in syntax. How should you add object-oriented functions to it, such as C.
And in the real world, this happened at least to perl.

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.