PHP Object-Oriented tutorial 1

Source: Internet
Author: User
  1. Object-oriented concepts
    OO programming (Object Oriented programming, OOP, object-oriented programming) is a kind of computer programming
    Architecture, the basic principle of OOP is that a computer program is composed of a single unit or object that can act as a subroutine, OOP
    It achieves the three goals of software engineering: reusability, flexibility, and extensibility. To achieve the overall operation, each object is able to receive
    Information, process data, and send information to other objects. Object-oriented has always been a hot topic in the field of software development, first of all,
    Object-oriented conforms to the general law of human beings ' view of things. Secondly, the use of object-oriented method can make each part of the system
    Do what you can. Open the door for programmers to make their programming code more concise, easier to maintain, and have a stronger weight
    The use of sex. Some people say that PHP is not a true object-oriented language, which is true. PHP is a mixed language and you can make
    Using OOP, you can also use traditional procedural programming. However, for large projects, you may need to use pure oop in PHP
    Declare the class, and use only objects and classes in your project. I'm not going to say much about this concept, because there are a lot of friends away from facing
    The main reason for programming is that you don't understand it when you touch an object-oriented concept, so you don't want to learn. Wait to read
    After reading the entire content, then go to the concept to understand it.
    2. What is a class, what is the relationship between the object, the class, and the object
    Class Concept: A class is a collection of objects that have the same properties and services. It provides a uniform for all objects that belong to the class
    The abstract description, which consists of two main parts of attributes and services. In an object-oriented programming language, a class is a separate process
    Unit, it should have a class name and include both the attribute description and the service description of the two main parts.
    Object concept: An object is an entity used to describe an objective thing in a system, which is a basic unit of a system. One
    An object consists of a set of properties and a set of services that operate on that set of properties. From a more abstract point of view, the object is a problem domain or
    An abstraction of something in a domain that reflects the information that the thing needs to be preserved in the system and the role it plays; it is a group of
    A set of services that are sexually and have permission to operate on these properties. The objective world is made up of the connections between objects and objects.
    The relationship between a class and an object is like the relationship between a mold and a casting, and the instantiation of a class is an object, and the abstraction of a kind of object is
    Class. Class describes a set of objects that have the same attributes (attributes) and the same behavior (methods).
    Above is probably their definition, perhaps you are just contact object-oriented friends, not to be confused by the concept of things, to
    You give an example, if you go to Zhongguancun to buy a few assembled PC, to where you first step to do, is not installed
    The engineer and you sit together, according to the information you provide with you to complete an installed configuration, this configuration list can be
    Elephant is a class, it is a piece of paper, but it records the PC you want to buy information, if you use this configuration to buy 10 machine
    Device, then these 10 machines, are based on this configuration single, so that the 10 machine is a type, can also be said to be
    Kind of. So what is an object, the instantiation result of the class is the object, which is configured with this configuration order (instantiated)
    The machine is the object, we can operate the entity, 10 machines, 10 objects. Each machine is independent and can only be explained
    They are of the same class, and any action on one of them does not affect the other 9 machines, but I modify the class
    This configuration list with one or fewer accessories, then the installed 9 machines have changed, this is the relationship between classes and objects (class
    The instantiation result is the object).
    3. What is object-oriented programming?
    Do not say his concept, if you want to set up a computer classroom, the first to have a room, the room to have n computers,
    There are n tables, n chairs, whiteboards, projectors and so on, what are these, just what we said, this is the object, can see
    To the entity, it can be said that this computer classroom unit is one of the entity objects, they together make up this
    The computer classroom, then we are doing the procedure, this and object-oriented has what relationship? Develop a system program and build a computer classroom
    Similarly, you abstract each individual function module into a class that forms an object that consists of multiple objects that are
    The ability to receive information, process data, and send information to other objects, among other things. constitutes an object-oriented program.


The above is the PHP object-oriented tutorial 1 content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!

  • 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.