php命名空间

//index.xphp
<?php
include('file1.php');
echo project_1\test1::t1();
//调用外部函数
echo project_1\t2();

//使用use重命名命名空间名称
use project_2 as project_3;
echo project_3\test1::t1();

 

//file1.php

<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2020/8/1
* Time: 22:14
*/
namespace project_1;
const INSTANCE=1;

function t2(){

echo 22;
}
class test1{

//只能是静态方法
static function t1(){
echo 11;
}



}

namespace project_2;
class test1{

//只能是静态方法
static function t1(){
echo 11;
}
}
posted @ 2020-08-01 22:38  快乐的在一起  阅读(131)  评论(0编辑  收藏  举报