php5.3 namespace
<?php
namespace LIB;
include 'test.php';//引入带命名空间的文件
include '__init__.php';//引入公共函数
class MySQL {}
class SQLite {}
function show()
{
return "111";
}
namespace LIB_EXTRA;
use LIB as T;//声明使用 空间LIB
class MScrypt {}
$a = new MScrypt();
function show()
{
return "ad";
}
use foo as F;
var_dump(
get_class($a),
T\show(),
F\abc(),
\foo\abc(),//直接使用命名空间调用函数
\common()//调用公共空间的函数
);
string 'LIB_EXTRA\MScrypt' (length=17) string '111' (length=3) int 151 int 151 string 'common' (length=6)
test.php
<?php
namespace foo;
class Xyz {}
function abc () {
return 151;
}
__init__.php
<?php
function common()
{
return "common";
}
参考:http://www.jb51.net/article/36389.htm
困难是老天给我们提高的机会,坚定不移勇敢地去攻克,不要退缩,加油!
posted on 2013-11-27 15:38 天地一连线_孤鸿挂飘渺 阅读(240) 评论(0) 收藏 举报
浙公网安备 33010602011771号