PHP language Knowledge class What is called Class _php tutorial

Source: Internet
Author: User
Www.Bkjia.com Tutorial Before we explain the concept of the class, let's talk about the concept of object-oriented programming: Object-oriented program design (object-oriented programming, précis-writers OOP) is intended to create software reuse code, with the ability to better simulate the real-world environment, This makes it recognized as the winner of top-down programming. It "encapsulates" a function into an "object" necessary for programming by adding an extension statement to the program. The object-oriented programming language makes complex work clear and easy to write. It is a revolution, not to the object itself, but to the ability of them to deal with their work. Objects are not compatible with traditional programming and programming methods, but are only partially object-oriented and make the situation worse. Unless the entire development environment is object-oriented, the benefits of the object do not have much trouble. One might say that PHP is not a true object-oriented programming language, PHP is a hybrid language, you can use object-oriented programming, or you can use traditional procedural programming. However, for the development of large projects, you might want to use pure object-oriented programming in PHP to declare classes, and only use objects and classes in your project development. As the project grows larger, using object-oriented programming can be helpful, object-oriented programming code is easy to maintain, easy to understand and reuse, which is the foundation of software engineering. Applying these concepts to Web-based projects is the key to future site success.

Object is an abstraction of a problem domain or something in the implementation domain that reflects the information and the role that this thing needs to be saved in the system; it is a set of attributes and a package of services that have permission to manipulate these properties. The object is to be understood in two ways: on the one hand refers to the real-world objects that the system is dealing with; On the other hand, objects are objects that are not directly processed by the computer, but are handled by the corresponding computer representations, which are also referred to as objects. Simply put, a person is an object, a ruler can also be said to be an object. When these objects can be directly represented by the data, we call him property, the ruler can be measured in centimeters, meters or feet, and this unit of measure is the ruler's attribute.

In PHP we can define a class that refers to a variable and a collection of functions that use those variables. PHP is a loosely typed language, so overloading by type overloading does not work, and it does not work with different numbers of parameters. Sometimes it is good to overload constructors in orientation, so that you can create objects in different ways (passing different numbers of parameters). In PHP, this is done through classes.

The following is the referenced content:
Class Class_name//In an object-oriented programming class, the first character in the customary class is uppercase and must conform to the naming convention of the variable.
{

A collection of functions and variables

}
?>

In PHP, a class is done to encapsulate the information, and the syntax for defining a class in PHP is:

The following is the referenced content:
Class Student
{
var $str _name; Name
var $str _sex; Gender
var $int _id; School Number
var $int _english; English score
var $int _maths; Math Scores
}
?>

When defining a class, you can define it in the format you prefer, but it's better to keep a standard so that it's more efficient to develop.

Data members are defined in a class using the "var" declaration, which is not typed until the data member is assigned a value. A data member can be an integer, an array, an associated array (associative array), or an object.

The following is a practical example of a class definition:

This is a simple example of a common definition class that shows the student's academic performance, and the class name Student,student class includes a student's basic attributes: Name, gender, school number, English score, and math score.

    • Total 3 Pages:
    • Previous page
    • 1
    • 2
    • 3
    • Next page

http://www.bkjia.com/PHPjc/364298.html www.bkjia.com true http://www.bkjia.com/PHPjc/364298.html techarticle Fire Net (liehuo.net) tutorial before we explain the concept of class, let's talk about the concept of object-oriented programming: Object-oriented program design (object-oriented programming, précis-writers for OOP) .

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