PHP5 Object-oriented (learning record) _php tutorial

Source: Internet
Author: User
Tags access properties
1, inheritance extends can only be inherited by single
Public protected Private Property
__construct ()
__destruct ()
__get () Read Private member
__set ($n, $v) set private members
2, access the parent class function:: (also called a scope character in C + +)
7
3, overloading functions with the same name as the parent class

4, abstract classes must inherit an abstract function that cannot be instantiated and must be overridden as long as a function in the class is static, then the class must be static

5, Common keywords
1,final when defining a class, a class cannot be inherited when a function cannot be overloaded
2,self used to access properties in an instantiated class or methods (static or constant) using the method self:: Property
3,static defines a static member or method only occurs once in memory (non-static content cannot occur within a static method)
4,const constants that define constants that can only be decorated with member properties are not added $
6, application of Interface interface interface Definition keyword implements reference
Interfaces: All abstract methods, without the abstract attribute should be a constant
Interface demo{}
Class T implements demo{} can refer to multiple interfaces
First inherit after interface Class A extends root implements demo{}
Interface inheritance Interface interface D extends Demo

7, polymorphic PHP is a weakly typed language, so support is not perfect.
Instanceof Tests whether an instance is from a class example:a{} $c = new A; if ($c instanceof a)
8, when the object is passed as a parameter to the function, the constructor is not run and is not a replica, but the object address is passed

9, Object Description configuration __tostring () {content} direct Echo Object

10, object exception handling __call ($name, $value) automatically absorbs your error when calling a nonexistent method name and displays the values of the $name and error parameters

11, Object clone __clone () put in class clone keyword (equivalent to C + + copy function)

12, Auto Load function __autoload ($class _n) {
Include ($class _n. ' php ');
Automatically load Inlcude () a class when you new class by itself

http://www.bkjia.com/PHPjc/320986.html www.bkjia.com true http://www.bkjia.com/PHPjc/320986.html techarticle 1, inheritance extends can only inherit public protected private property __construct () __destruct () __get () read Private member __set ($n, $v) set Private member 2 to access the parent class function:: (c + + ...

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