Copy codeThe Code is as follows: /**
* Strategy Mode (Strategy. php)
*
* Define a series of algorithms, encapsulate them one by one, and make them replace each other. Changes in the used algorithms can be independent of customers who use them.
*
*/
The three main characteristics of the aspect direction: encapsulation, inheritance, and Polymorphism:
When we first define a class, we actually extract the common attributes and behaviors of a class of things to form a physical model (Template).
This article mainly introduces the usage of _ initialize () and construct _ construct () in ThinkPHP, and analyzes the method of constructing subclass during class initialization in ThinkPHP as an example, thinkPHP is an important concept in
Ec (2); php automatically loads function _ autoload () PHP before the magic function _ autoload () method appears, if you want to instantiate 100 objects in a program file, you must use include or require to include 100 class files, or you can
Public: The public type can call the public method or attribute through self: var in the subclass. parent :: the method calls the parent class method. You can use $ obj-var in the instance to call the public type method or attribute protected: the
Section 6 -- access attributes and Methods
The attribute of an object instance is a variable, just like other variables in PHP. however, you must use the-> operator to reference them. $. for example, in 6.1, print the row of the name attribute of
_ Initialize () and constructor _ construct () in thinkphp ()There are a lot of comments and usage about _ initialize () on the Internet, which are not correct, so I tested it myself. Share the results with you. Correct the error.First, I want to
PHP note: Detailed description based on object-oriented design. Public indicates Global, which can be accessed by external sub-classes inside the class. copy the code as follows :? PhpclassTest {public $ nameJanking, $ sexmale, $ age23; function _
The modifier mode dynamically attaches the responsibility to the object. If you want to expand functions, the decorator provides an alternative solution that is more flexible than inheritance.
The modifier mode dynamically attaches the
Daily one-mode php Adapter mode
/*** Adapter mode: adapt the interface of an object to another */interface Seller {public function compute ();} // scenario: Chinese herbal medicine, buy directly, sell the class HerbalMedicine {private $ _ medicine, $
Php object-oriented? Is Final Php object-oriented? Final class
Class. only instantiated objects cannot be used for inheritance.
When designing, this class can no longer be extended, so we should use the final syntax to limit it. other users
PHP design pattern-Command pattern statement: This series of blog reference material "big talk design pattern", author Cheng Jie.
Command mode: in software systems, "behavior requestor" and "behavior implementer" usually present a "tightly
PHP memory overflow Allowedmemorysizeof solution ============================ Allowedmemorysizeof? Xxxbytes? I have tracked this problem before, but at that time the tool was not used very well. I didn't see it so carefully. this time I made a
The attribute of an object instance is a variable, just like other variables in PHP. however, you must use the-> operator to reference them. $. for example, in 6.1, print the row of the name attribute of the user object.
You can use this
PHP design mode-Visitor Mode
Visitor mode indicates an operation that acts on each element in an object structure. It allows you to define new operations that act on these elements without changing the element classes.
UML class
Inheritance
These classes are usually required. These classes have the same variables and functions as other existing classes. In fact, defining a general class for all projects and constantly enriching the class to adapt to each specific project is
[What is MVC ?] MVC is a concept that allows you to combine the "three parts (the full name of MVC, Model, View, Controller)" into a complex application. A car is a very good example of MVC in real life. We can View both the internal View and the
Dynamically add some additional responsibilities to an object, which is more flexible in terms of the extension function than the subclass generation method.
The code is as follows:
/**
* Decoration mode
*
* Dynamically add some additional
Encapsulate a request as an object so that you can parameterize the customer with different requests, exclude or record the request logs, and support cancelable operations.
The code is as follows:
/**
* Command mode
*
* Encapsulate a request as an
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.