function uppercase($text)
{
$e = new textEngine;
return($e->uppercase($text));
}
}
//test class in namespace 测试命名空间中的类
$e = new core_php:utility::textEngine;
print($e->uppercase("from object") 。
"<br>");
//test function in namespace 测试命名空间中的函数
print(core_php:utility::uppercase("from function") 。
"<br>");
//bring class into global namespace 把类导入全局命名空间
import class textEngine from core_php:utility;
$e2 = new textEngine;
?> Import 语句把命名空间中的某个部份导入全局的命名空间。
要导入单一的命名空间的成员,可以指定类型为 constant,function 或 class,接着写上成
员的名称;
//如 import class XXX
如果你想导入某一特定类型的所有成员,你可以用*来代替名称;
//如
import constant * 导入所有常量
如果你想导入所有类型的所有成员,用*即可。
//如
import *
在成员之后,用 from 关键字加上命名空间的名称。
//如
import class textEngine from core_php:utility;
总 之 你 要 写 成 像 import * from myNamespace 或 import class textEngine from
core_php:utility 这样的语句,就像例子中那样。