downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

class_exists> <call_user_method
Last updated: Fri, 24 Jul 2009

view this page in

class_alias

(No version information available, might only be in CVS)

class_aliasCreates an alias for a class

설명

boolean class_alias ([ string $original [, string $alias ]] )

Creates an alias named alias base 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)

참고



add a note add a note User Contributed Notes
class_alias
paul [dot] kotets [at] gmail [dot] com
03-Sep-2009 10:43
This function will appear in PHP 5.3 (at least I can use it with PHP 5.3, build Aug 7 2009 08:21:14)
For older versions of PHP I wrote the next function:

<?php
if (!function_exists('class_alias')) {
    function
class_alias($original, $alias) {
        eval(
'abstract class ' . $alias . ' extends ' . $original . ' {}');
    }
}
?>

Keyword 'abstract' is used for classes, which defines abstract methods.
This function is used in autoload purposes (when I extend classes), so abstract keyword doesn't broke anything for me.

class_exists> <call_user_method
Last updated: Fri, 24 Jul 2009
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites