Knowledge Point sorting of Surface object objects in PHP, and knowledge point of php surface object

Source: Internet
Author: User

Knowledge Point sorting of Surface object objects in PHP, and knowledge point of php surface object
Object-oriented: all objects are objects, and transactions that constitute a problem are decomposed into various objects. The purpose of object creation is not to complete a task, but to describe the behavior of a transaction in solving the problem, it is more in line with people's thinking habits, high code reusability, and scalability. ______________________________________________________________________________ a conceptual class is an abstract concept. It is a set of objects with the same semantics (a group with the same attributes and methods). It is not feasible to use a specific class, it can only be instantiated. Taking cars as an example, the design drawings of automobiles are class and automobiles are objects. In the design, the key point is to create a class. In real life, all things are objects. If the specific computer we use is an object, then the computer is a class. When you pick up a child in kindergarten, you say you pick up the child, and people will never give it to you (unless you know you and who your child is). You must name your child, your child is a specific object, and the child is a class name writing specification class name first letter capitalized a class is defined in a file, and. class. php serves as the end of the file name ______________________________________________________________ object handle to distinguish different objects. After an object is created, obtain a bucket in the memory. The address of the bucket is the variable defined in the class of the object's identity or handle attribute, that is, the member attribute, data used to describe the static characteristics of an object. For example, a person's name, gender, and lowercase letter method function is defined as a member method in the class. It is used to describe the operation behavior of an object's dynamic characteristics. The method name is case-insensitive and cannot be duplicated, after the life cycle of the lower-case object is created, the life cycle starts. After the program ends or the programmer clears the object, PHP will automatically destroy the object after the object's life cycle 1 program is executed, PHP runs the recycle mechanism to delete objects in the memory. 2. After deleting all objects, the objects are junk, the recycle mechanism automatically deletes junk objects. Step 1. Open the object space in the content. 2. Execute the constructor. 3. Return the object reference address to the object memory distribution: 1. The object reference is stored in the "stack memory" (the stack stores fixed content). 2. The object is stored in the "heap memory" (heap stores variable content) 3. Static members are placed in the "Data zone". When they are loaded for the first time, each object in the heap memory can share 4 functions and methods in the Code zone.

The object-oriented feature abstraction abstracts the common attributes and methods of A Class Object to form a class. This way of thinking is abstract encapsulation: encapsulates member methods and member attributes into the class, hide attributes and methods, hide the details of method implementation, and use public protected private final static to limit the access permissions of class members. Data is protected internally, only authorized member methods can be used. Encapsulate and inherit extends for Members as much as possible: You can make a class inherit and own the member attributes and methods of another existing class. The inherited class is called the parent class or the base class, the inherited class is a subclass. Extends keywords realize inheritance relationship polymorphism: subclass inherits the parent class, and implements polymorphism through rewriting of the parent class method _____________________________________________________________________________________________________ access modifier (scope descriptor) publlic can be accessed both inside and outside the class or by sub-classes. It is the most open permission to private the attributes and methods of the definition class and can be accessed within the class, you cannot access the attributes and methods of the protected definition class of protected outside the class or the subclass of the class, strong cohesion in the module design is not accessible to the outside of the class (functions should be completed within the class as much as possible), and weak coupling (as few open methods as possible for external calls ). For example, the company's sales project is handed over to the company's internal programmers, designers, and server management personnel to coordinate and complete ______________________________________________________________________ static attributes and static methods require a data object to serve only the class, that is, the class is available internally and is unavailable externally. Object creation is extremely resource-consuming. Therefore, when a method is highly available, it is not necessary to re-generate an instance of this type to call this method. The defined methods or variables reside in the memory when the program is loaded for the first time, and the program ends and is released. Static methods cannot be overwritten by non-static methods. The constructor cannot declare static variables as static variables. The member variables declared through static are static variables or class variables, which are public variables of the class, it is generated when it is used for the first time. There is only one copy of all objects in the class, which belongs to the class rather than the object. Static variables belong to a class but not an object. They can be accessed from the local class anywhere. They are global variables of the class and are stored in the memory when the class is created. For multiple objects, only one static data member is stored, saving memory. You only need to update the value of the static data member once to ensure that the updated value is the same for all objects. Static Method: The method declared with static is a static method or a class method. When executing this method, the object is not referenced to the function, so we cannot access non-static members, you can only access static methods or static variables. Only classes such as self static parent can be used. $ This self: parent ::$ this is a reference to the current object. It is usually used in methods to obtain the member attributes of a class, or the execution class member method self: Reference to this class, used to obtain the current class's statement member attribute or static member method self: run () parent: Reference to the parent class, call the method or attribute of the parent class. _________________________________________________________________________________ Constructor & constructor _ construct () is automatically executed when an object is created, and no return value is returned for initialization of the class, such as object attribute initialization, in PHP4, the constructor must have the same name as the class. In php5, the constructor is _ construct (). The advantage is that it is not affected by the class name, if _ construct php does not exist, the method with the same name as the class is automatically executed. You can pass parameters in the constructor to define attributes. When both the parent class and the subclass define the constructor, execute the constructor of the subclass _ destruct (): this method is used to automatically execute an object when it is destroyed in the memory, without any parameters _____________________________________________________________________________ object final const

  1. // The methods in the class cannot be modified.
  2. // The class cannot be inherited
  3. final class souji {
  4. Final public $ pinpai; // Error
  5. Final function congdian () {// invalid
  6. Echo $ this-> pinpai. "The mobile phone is charged at 10 V voltage ";
  7. }
  8. public function kaijidonghua() {
  9. Echo "<no boot animation >>>> ";
  10. }
  11. }
  12. class moto extends souji {
  13. public function __construct() {
  14. // $ This-> pinpai = "Motorola ";
  15. $this->congdian();
  16. }
  17. public function kaijidonghua() {
  18. Echo "Motorola trademark ";
  19. }
  20. }
  21. $li = new moto();
  22. $li->kaijidonghua();
  23. // Define a constant
  24. Define ("WEBNAME", "");
  25. function aa(){
  26. Echo WEBNAME. "Focus on PHPWEB development ";
  27. }
  28. aa();
  29. class caiwu{
  30. const suilv=0.05;
  31. function __construct(){
  32. echo WEBNAME;
  33. }
  34. function kaigonzi($xingming,$gongzi){
  35. $gongzi = $gongzi-$gongzi*self::suilv;
  36. Return $ xingming. "The salary is:". $ gongzi. "RMB ";
  37. }
  38. }
  39. /* Employee class */
  40. class yuangong{
  41. Private $ xingming; // name
  42. Private $ gongzisu; // salary
  43. function __construct($xingming,$gongzisu){
  44. $this->xingming = $xingming;
  45. $this->gongzisu = $gongzisu;
  46. }
  47. function kaizi(){
  48. $caiwu = new caiwu();
  49. return $caiwu->kaigonzi($this->xingming, $this->gongzisu);
  50. }
  51. }
  52. $ Lisi = new yuangong ("Li Si", "6000 ");
  53. echo $lisi->kaizi();

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.