update : 2015.11.03
php.shukuma.com

검색:
 
 
Creates an alias for a class

class_alias

(PHP 5 >= 5.3.0, PHP 7)

class_aliasCreates an alias for a class

설명

bool class_alias ( string $original , string $alias [, bool $autoload = TRUE ] )

Creates an alias named alias based on the user 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.

autoload

Whether to autoload if the original class is not found.

반환값

성공 시 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)

참고