class_alias
(PHP 5 >= 5.3.0)
class_alias — Creates an alias for a class
说明
bool class_alias ([ string $original [, string $alias ]] )Creates an alias named alias based on the defined class original. The aliased class is exactly the same as the original class.
参数
- original
-
The original class.
- alias
-
The alias name for the class.
返回值
成功时返回 TRUE, 或者在失败时返回 FALSE.
范例
Example #1 class_alias() example 以上例程会输出:
<?php
class foo { }
class_alias('foo', 'bar');
$a = new foo;
$b = new bar;
// the objects are the same
var_dump($a == $b, $a === $b);
var_dump($a instanceof $b);
// the classes are the same
var_dump($a instanceof foo);
var_dump($a instanceof bar);
var_dump($b instanceof foo);
var_dump($b instanceof bar);
?>
bool(true)
bool(false)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
参见
- get_parent_class() - 返回对象或类的父类名
- is_subclass_of() - 如果此对象是该类的子类,则返回 TRUE