PHP Object-oriented design pattern

Source: Internet
Author: User
Tags php language

  Why Study Design Patterns:
1, more in-depth understanding of object-oriented thinking
2, is conducive to the development of a strong extension of things

  

What is a design pattern: a typical solution for a typical scenario that often occurs is the design pattern. For example, in the life of the design patterns: such as the idea of girls, chess tricks and so on. So how to learn design patterns? Typical scenario-"typical problem"--typical solution

Polymorphic

Polymorphism is a biological concept, refers to the same kind of various forms of expression, such as: Crucian carp generally in a catty or so, silver carp generally in more than 10 kilograms, in object-oriented, refers to some kind of object (such as a tiger) instances of different manifestations, such as some tigers will climb trees, some will not. In a strongly typed language Java, function parameters, function return values are dead, and when a class wants to implement different processing, we usually only declare abstract class, specific work is done by the subclass object, because the subclass belongs to the parent class, so when we use, passed the parent class object can implement different functions, This is the polymorphism of Java. PHP is a weak type of language, a variable does not have a type, you can do anything, the same, there is no mandatory type of parameters, the transfer of anything, so for the PHP dynamic language, is not polymorphic, but the metamorphosis, in order to make PHP not so flexible, we have to restrict the parameter type, the parameter is the parent class, pass its subclasses PHP language itself is polymorphic, after php5.3, the introduction of object type parameter detection (can only detect the object belongs to the Class), which limits the flexibility for PHP, to achieve the multi-state effect in Java

thinking: Polymorphism is actually referring to the abstract declaration of the parent class, the specific work of sub-class object completion, such as the completion of different subclass objects, there are different characteristics .

Cond...

PHP Object-oriented design pattern

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.