Classkit 函数
PHP 手册

classkit_import

(PECL classkit >= 0.3)

classkit_importImport new class method definitions from a file

说明

array classkit_import ( string $filename )

Note: 本函数不能用于操作当前正在运行(或运行链上)的方法。

Warning

本函数是实验性的。本函数的行为,包括函数名称以及其它任何关于本函数的文档可能会在没有通知的情况下随 PHP 以后的发布而改变。使用本函数风险自担。

参数

filename

The filename of the class method definitions to import

返回值

Associative array of imported methods

范例

Example #1 classkit_import() example

<?php
// file: newclass.php
class Example {
    function 
foo() {
        return 
"bar!\n";
    }
}
?>
<?php
// requires newclass.php (see above)
class Example {
    function 
foo() {
        return 
"foo!\n";
    }
}

$e = new Example();

// output original
echo $e->foo();

// import replacement method
classkit_import('newclass.php');

// output imported
echo $e->foo();

?>

上例将输出:

foo!
bar!

参见


Classkit 函数
PHP 手册