classkit_import

(PECL classkit >= 0.3)

classkit_importImport new class method definitions from a file

说明

classkit_import ( string $filename ) : array

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!

参见