PHP - Manual: Yaf_Loader::registerLocalNamespace
2024-11-14
(Yaf >=1.0.0)
Yaf_Loader::registerLocalNamespace — 注册本地类前缀
prefix
字符串或者是数组格式的类名前缀,所有拥有和这些前缀相同前缀的类将被加载到本地library路径。
bool
示例 #1 Yaf_Loader::registerLocalNamespace()example
<?php
$loader = Yaf_Loader::getInstance('/local/library/', '/global/library');
$loader->registerLocalNamespace("Baidu");
$loader->registerLocalNamespace(array("Sina", "Weibo");
$loader->autoload("Baidu_Name"); // search in '/local/library/'
$loader->autoload("Sina"); // search '/local/library/'
$loader->autoload("Global_Name");// search in '/global/library/'
$loader->autoload("Foo_Bar"); // search in '/global/library/'
?>
官方地址:https://www.php.net/manual/en/yaf-loader.registerlocalnamespace.php