PHP, etc.

Source: Internet
Author: User
PHP and other class-related functions 1. same class knowledge as Java 1. class and object public, private, constructor, thisClassperson {public $ length; member variable _ construct () {Constructor} publicfunctiongetLength () {Member method echo $ this-& g PHP and so on
Class functions

I. same class knowledge as Java
1. classes and objects
Public, private, constructor, this
Class person {public $ length; // member variable _ construct () {// Constructor} public function getLength () {// member method echo $ this-> length ;} private function myDisplay () {// private method} // static variable, static method}


2. Inheritance and derivation (core)
(1) inheritance-inherits the parent variables and methods.
(2) load and overwrite data in child classes
(3) use static methods or static variables for global use.

3. Interface
It seems that php does not exist.

2. PHP classes are different from Java classes
In comparison, object-oriented php is much simpler than java. Java is essentially interface-oriented programming (an advanced form of object-oriented programming ). Php is a true and pure object-oriented programming.
Therefore, MVC in php is true MVC, only the view layer-control layer-model layer.
Java MVC is actually layer 5, namely the control layer-service/serviceImpl-data persistence layer (dao/daoImpl)
I prefer the MVC model of php, because it is very simple this time and should not be complicated.

III. php object-oriented programming functions
Compared with java, php does not have a reflection mechanism, but it also has its own unique methods.
1, get_class () get the 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.