[Process-oriented & object-oriented]
* 1, focus on the process of solving a problem. The greatest feature of process-oriented is the process of solving this problem by a function of one.
* 2, focus on which object to deal with a problem. The most important feature of object-oriented is that it has a class with attributes and functions, and gets the object from the class to deal with the problem.
*
* "Object Oriented"
* 1, what is a class?
* A set of individuals with the same attributes (characteristics) and methods (behaviors), classes are an abstract concept
* 2, what is an object?
* From the class, get the individual with the specific attribute value, called the object. object is a specific individual.
*
* Human beings have names, genders, and ages, but none of these attributes can have a specific value.
* Zhang San, is one of the objects of mankind! Name Zhang San, gender male, age 23, after each attribute of the class is assigned a specific value, it becomes the Zhang San object.
*
* 3. What are the relationships between classes and objects?
* Class is the abstraction of an Object! Object is the materialization of the class!
The * class simply indicates which properties of such an object, but cannot have a specific value, so the class is abstract.
* Whereas an object is to assign all properties of a class to a specific individual, all objects are specific.
*
* "Declaration and instantiation of a class"
* 1, how to declare a class:
* Class Name {
* Access modifier $ Property [= default value];
* [Access modifier] Function method () {}
* }
*
* 2, the notice of the declaration of a class:
*① class name can only have alphanumeric underline composition, the beginning can not be a number, must conform to the large hump law;
The *② class name must be modified using class, and must not have () after the class name;
The *③ property must have an access modifier, and the method can have no access modifier;
*
* 3, Instantiate object and object property method call?
* $ Object name = new class name (); () can not take
*
* Class external call properties and methods:
* $ object Name, property name; When using the Invoke property, the property name cannot be taken with the $
*
* Class internal call properties and methods:
* $this property name;
*
* "Constructors"
* 1, what is a constructor function?
* A constructor is a special function in a class that is equivalent to invoking the constructor of a class when we instantiate an object with the new keyword;
*
* 2. What is the function of the constructor?
* When instantiating an object, automatic invocation is used to assign an initial value to an object's properties!
*
* 3. How to construct the constructor?
*① constructor name, must have the same name as the class
* [public] function person ($name) {
* $this, name = $name;
* }
*② using the Magic method __construct
* [public] function __construct ($name = "") {
* $this, name = $name;
* }
*
*
* 4, the construction function notes:
*① the first one, the constructor name must have the same name as the class!!!!!!
*② if a class does not have a handwriting constructor, the system will have an empty parameter construct by default, so you can use the new person ();
* If we write a constructor with parameters, there will be no more null parameter constructs, that is, the new person () cannot be used directly; The parameter list in the () after person must conform to the requirements of the constructor!!!
*③ If two constructors exist at the same time, __construct will be used.
*
*
* 5, destructor: __destruct ():
The *① destructor is automatically called before the object is destroyed!
*② destructors cannot have any arguments
*③ destructors are commonly used when objects are exhausted, freeing resources, closing resources, and so on!
*
*
* 6, Magic Method:
* In PHP, we provide a series of functions that begin with __, which do not need to be called manually, and will be called automatically at the right time, such functions are called magic functions.
* For example: function __construct () {} is automatically called when class new is an object
* Function __destruct () {} is called automatically when an object is destroyed
*
* We require that, in addition to the Magic method, custom functions and methods cannot start with __.
*
*
* Finally, for classes with more complex functions, we will write to a class file separately.
* class file naming, unified lowercase, using the "class name lowercase. class.php" way named.
* When using this class in other files, you can import this. class.php file with include.
PHP Object-oriented--1, basic