English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP Class/Object function reference manual
The class_alias() function creates an alias for a class
class_alias(string $original, string $alias[, bool $autoload = TRUE]);
Create an alias alias based on the user-defined class original. This alias class is completely the same as the original class.
Number | Parameters and descriptions |
---|---|
1 | original (required) Original class. |
2 | alias (required) Class alias. |
3 | autoload (optional) Whether to use automatic loading (autoload) if the original class has not been loaded. |
Returns TRUE on success, or FALSE on failure.
The following is the usage of this function-
<?php class foo { } class_alias('foo', 'bar'); $a = new foo; $b = new bar; //Whether the objects are the same var_dump($a == $b, $a === $b); var_dump($a instanceof $b); //Whether the class is the same var_dump($a instanceof foo); var_dump($a instanceof bar); var_dump($b instanceof foo); var_dump($b instanceof bar); ?>Test and see ‹/›
Output result:
bool(true) bool(false) bool(true) bool(true) bool(true) bool(true) bool(true)