日期:2011-05-19 浏览次数:20554 次
<?PHP
namespace core_PHP:utility
{
class textEngine
{
public function uppercase($text) //大写
{
return(strtoupper($text));
}
}
//make non-OO interface 建立一个非OO的接口
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;
?>