php5新添加了好多的新函数和特征,但是在目前最新的chm的手册中都没有体现,要到在线的手册中查找,烦啊!
废话不多说了,来看看php5中全新的class对比php2的class有什么新的特征。
1/ 加了访问权限的控制:使用private/public/protected的特征
2/ 加入了接口和抽象类的概念,interface/abstract,可惜的是类的继承还是树形的单继承。
3/ 可以定义final 函数,不能在父类中覆盖这个函数
4/ 终于可以在类中定义 静态的变量,在php中只能在函数中定义,static $aa = nulll;,另外还提供了 const 方法const mystatic = 'aaaaaa';
5/ 新提供了一个self内部方法 echo self::mystatic;
6/ 加入了如下的内部特征
__construct() 初始化
__destruct(); 卸载
__get(); 组织返回类中的某些变量值。
__set(); 组织给类中的某些变量值赋值。
__call(); 调用不存在的类的函数的时候得处理方法
__clone(); copy对象用
__sleep(); 序列化的时候用
__weekup(); 反序列的时候用
7/ 默认的object的赋值采用了应用的方式,如:
$object2 = $object1
$object2 得到的是$object1的引用,不是在内存中copy副本
8/ 提供了 reflection API ,主要用来显示class/function 本省的结构和统计信息,这个是一个全新的东西,很难说清楚,(虽然很强大,但是我个人还是没有找到“这位英雄可以用武的地方”)
9/ 对class对象提供了一个枚举的功能,可以用for循环来处理对象中的全局的变量。
10/ 提供了一个__autoload();函数,用来自动的加载类声明文件

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Chinese version
Chinese version, very easy to use

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function