This paper summarizes several points in the object-oriented inheritance of PHP:
People.class.phpclass people{private $name;p rivate $sex;p rivate $birthday;p rivate function construct ($name = ", $sex = ' n ', $birthday = ' 1999-01-01 ') {echo '
Classes and objects > access Control (visibility)Objects of the same class can access each other's private and protected members, even if they are not the same instance. This is due to the fact that the specifics of the implementation within these
PHP destructor Call
Class a{ function construct () { echo "start to construct a obj\n"; } function pide ($a, $b) { //exit (1),//destruct called return $a/$b;//destruct called when $b =0; } function
For PHP query MySQL database model.php writing is not perfect, in each method also need to declare the MySQL $con object, and shut down the MySQL $con object. This way, if you query more than one method, you add a lot of code to declare $con objects
PHP5 after the implementation of some magic method or more interesting, has been using a process-oriented programming method, the study of OOP less, recently in the look at oop things, or more interesting.
Magic method These things, feel a large
This article is mainly for the introduction of the PHP construction method in the inheritance of the destructor method in the performance, interested in the small partners can refer to
This article for you to share the PHP construction method of
PHP is a single-inheritance language, and PHP's class cannot inherit properties or methods from two base classes at the same time before PHP 5.4 traits appears. PHP's traits is similar to the Go language, which declares the trait name to be combined
This article mainly introduces the use of class inheritance in PHP to solve the problem of code duplication, example analysis of the principle of inheritance and use of skills, very practical value, the need for friends can refer to the next
The
Building objects is an important topic in the design of object-oriented programming in PHP. In the simplest case, the normal constructor is sufficient, but if more complex designs are to be implemented, the constructors may become unmanageable
Here'
recently, in the development process, we need to get the parameter number, name and parameter order of a class method, so that we can take the value from $_get according to the name of the parameter.
If the method prototype is test ($uid, $score),
Delegate Mode
is a basic technique in software design patterns. In delegate mode, there are two objects involved in processing the same request, and the object that accepts the request delegates the request to another object for processing. The
Interface
PHP class is a single inheritance, that is, do not support multiple inheritance, when a class requires multiple classes of functionality, inheritance is powerless, and for this reason PHP introduced interface technology
If all the methods
The difference between an abstract class and an interface
An interface is a special abstract class and can also be seen as a specification of a model. Interfaces are roughly different from abstract classes:
A subclass if you implements an interface,
A new version of PHP follows a number of new features, one of the more striking features is the support for closures. After that, can we write very cool code like the guys who write Ruby, Javascript, and so on, "high-tech language"?
Well, in fact,
Public: Common property or method
Can be called by Self::var or Self::method in a subclass, you can invoke a method in the parent class by Parent::method, but you cannot call the public property.
You can invoke the $obj->var or Self::method in the
This article mainly introduced the PHP reflection class Reflectionclass usage, combined with the case form more detailed analysis of the PHP reflection class concept, function and specific use method, the need for friends can refer to the following
characteristics of abstract classes
1. A class that is defined as abstract cannot be instantiated.2. If at least one of the methods in it is declared abstract, then the class must be declared abstract.3. A method defined as abstract simply
This article mainly introduces Symfony2 for input time query method, combined with instance form analysis Symfony2 for MySQL and MongoDB input time for conversion and query related operation skills, need friends can refer to the next
The examples
I'm using the thinkphp framework.
Encounter a scene, the consignor after the delivery of a user to send a notification message, efficiency is too low, so I thought of the template text messages,
To the problem of efficiency, I was designed like
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