PHP等等

Jun 13, 2016 am 10:50 AM
function java length mvc php

PHP之类
关于类的函数

一、与Java相同的类知识
1,类和对象
公有、私有、构造函数、this

Class person{  public $length;  //成员变量  __construct(){    //构造方法  }  public function getLength(){  //成员方法    echo $this->length;  }  private function myDisplay(){ //私有方法  }  //静态变量、静态方法}
Copy after login


2,继承和派生  (核心)
(1)继承——继承父类变量和方法。
(2)在子类中进行重载和覆盖
(3)使用静态方法/静态变量,全局直接使用。

3,接口
貌似php里没有。

二、PHP类与Java不一样的地方
相比较而言,php中的面向对象比java要简单很多。java本质是面向接口编程(面向对象编程的高级形式)。而php是真正、纯粹的面向对象编程。
所以php中的MVC是真正的MVC,只有视图层-控制层-模型层三层。
则java的MVC实际是5层,分别是控制层-业务逻辑层(service/serviceImpl)-数据持久层(dao/daoImpl)
我更倾向php的MVC模型,因为本次就很简单的东西,就不应该把他复杂化。

三、php面向对象编程相关的函数
与java相比,php并没有反射机制等,但也有自己独有的一些方法。
1,get_class()  获取类名



Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article

Hot Article

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

How To Set Up Visual Studio Code (VS Code) for PHP Development

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

PHP Program to Count Vowels in a String

Break or return from Java 8 stream forEach? Break or return from Java 8 stream forEach? Feb 07, 2025 pm 12:09 PM

Break or return from Java 8 stream forEach?

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

How do you parse and process HTML/XML in PHP?

Java Made Simple: A Beginner's Guide to Programming Power Java Made Simple: A Beginner's Guide to Programming Power Oct 11, 2024 pm 06:30 PM

Java Made Simple: A Beginner's Guide to Programming Power

Create the Future: Java Programming for Absolute Beginners Create the Future: Java Programming for Absolute Beginners Oct 13, 2024 pm 01:32 PM

Create the Future: Java Programming for Absolute Beginners

Java Program to Find the Volume of Capsule Java Program to Find the Volume of Capsule Feb 07, 2025 am 11:37 AM

Java Program to Find the Volume of Capsule

See all articles