Polymorphism in PHP

Source: Internet
Author: User

The exact meaning of polymorphism is that when an object of the same class receives the same message, it gets different results. And the news is unpredictable. Polymorphic, as the name implies, is a variety of states, a variety of results.

In Java, for example, because Java is a strongly typed language, the return values of variables and functions are stateful. For example, to implement the function of an add function, its parameters may be two int, or two float floating-point number, and the return value may be integer or floating-point type. In this case, the Add function is stateful, and it has several possible run results. When actually used, the compiler automatically matches the appropriate function. This is the concept of function overloading. It is necessary to note that overloading is not an object-oriented thing, and polymorphism is not a concept, it is a representation of polymorphism. Polymorphism is a programmatic way of describing the same object through multiple states or stages. What it really means is that in real-world development, if you care about the programming of an interface or a base class, you don't have to care about the specific class that an object belongs to. Many places see the phrase "PHP is not polymorphic." In fact, it is not that it is not, but it is polymorphic. PHP as a scripting language, itself is polymorphic, so at this level of language, do not talk about PHP polymorphism.

Polymorphism in PHP

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.