保留字列表
在线手册:中文  英文

预定义类

本节列出标准的预定义类。各种扩展库定义了其它类,其说明在各自的参考文档中。

标准类

这些类由一些内建在 PHP 中的标准函数定义。

Directory
dir()创建.
stdClass
__PHP_Incomplete_Class

自 PHP 5 起预定义的类

这些额外的预定义类是 PHP 5.0.0 引进的。

exception
php_user_filter

Closure

PHP5.3.0中引入了一个预定义的final类Closure,它可以用于实现 匿名函数

该类的构造方法禁止手工创建该类的对象(会导致一个E_RECOVERABLE_ERROR错误)。该类也有一个__invoke 方法来进行魔术调用

特殊的类

以下标记符不可以作为类名,因为它们有着特殊的用途。

self
parent

保留字列表
在线手册:中文  英文

用户评论:

spark at limao dot com dot br (2011-08-15 14:21:21)

if you want a Dynamic class you can extend from, add atributes AND methods on the fly you can use this:
<?php
    
class Dynamic extends stdClass{
        public function 
__call($key,$params){
            if(!isset(
$this->{$key})) throw new Exception("Call to undefined method ".get_class($this)."::".$key."()");
            
$subject $this->{$key};
            
call_user_func_array($subject,$params);
        }
    }
?>

this will accept both arrays, strings and Closures:
<?php
    $dynamic
->myMethod "thatFunction";
    
$dynamic->hisMethod = array($instance,"aMethod");
    
$dynamic->newMethod = array(SomeClass,"staticMethod");
    
$dynamic->anotherMethod = function(){
        echo 
"Hey there";
    };
?>

then call them away =D

Typer85 at gmail dot com (2007-02-17 08:58:57)

In response to the note below mine,
This list is not incomplete. Read the Manual folks, its listed there plain and simple:
"This section lists standard predefined classes. Miscellaneous extensions define other classes which are described in their reference."
Depending on what extensions you have, they might define their own classes. This list is just the standard classes as defined by PHP with no regards to extensions.

Simon Kissane (2004-09-14 00:54:18)

The above list is incomplete. For example, on my PHP 5.0 configuration (yours may differ depending on the extensions you choose to install), the following classes are predefined:
== "Core" ==
stdClass
Exception
__PHP_Incomplete_Class
php_user_filter
Directory
== Reflection API ==
ReflectionException
Reflection
ReflectionFunction
ReflectionParameter
ReflectionMethod
ReflectionClass
ReflectionObject
ReflectionProperty
ReflectionExtension
== SQLLite ==
SQLiteDatabase
SQLiteResult
SQLiteUnbuffered
SQLiteException
== Standard PHP Lib. ==
RecursiveIteratorIterator
FilterIterator
ParentIterator
LimitIterator
CachingIterator
CachingRecursiveIterator
ArrayObject
ArrayIterator
DirectoryIterator
RecursiveDirectoryIterator
== SimpleXML ==
SimpleXMLElement
SimpleXMLIterator
== DOM/XSL/XPath extensions ==
DOMException
DOMStringList
DOMNameList
DOMImplementationList
DOMImplementationSource
DOMImplementation
DOMNode
DOMNameSpaceNode
DOMDocumentFragment
DOMDocument
DOMNodeList
DOMNamedNodeMap
DOMCharacterData
DOMAttr
DOMElement
DOMText
DOMComment
DOMTypeinfo
DOMUserDataHandler
DOMDomError
DOMErrorHandler
DOMLocator
DOMConfiguration
DOMCdataSection
DOMDocumentType
DOMNotation
DOMEntity
DOMEntityReference
DOMProcessingInstruction
DOMStringExtend
DOMXPath
XSLTProcessor

unknown (2002-07-23 10:29:06)

It's handy to have a array of the reserved classes.....
var_dump (get_declared_classes ());

易百教程