PHP and MySQL programming object-oriented PHP

Source: Internet
Author: User
PHP and MySQL programming object-oriented PHP object access methods and attributes are similar to Java, including public, protected, private, final, and static.

6.3 constructor and Destructor

Function _ construct/destruct (args ...){

...

6.4 static class members

Class Visitor {

Private static $ visitors = 0;

Function f (){

Self: $ visitors ++;

}

Static function getVisitors (){

Return self: $ visitors;

}

6.5 instanceof and other auxiliary functions (similar to Java reflection)

OOP features not supported by PHP:

Method overload, operator overload, and multi-inheritance.

7.2 object cloning

PHP4 regards the object as the data type, and PHP5 regards the object as a reference by default.

$ Obj1 = clone $ obj2;

Override the _ clone method of the object to adjust the clone behavior.

7.3 inheritance

Class Employee {...}

Class Executive extends Employee {...}

Class CEO extends Executive {...}

Constructor:

Function _ construct ($ name ){

Parent: :__ construct ($ name );

Echo"

CEO created!

";

7.4 interface

Interface interfaceName {

CONST 1;

Const n;

Function method1 ();

Function method2 ();

Class Class_name implements interfaceName {

Function method1 (){

...

}

Function method2 (){

...

}

7.5 abstract class

Abstract class Class_Name {

...

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.