- 入口文件:
index.php
<?php
require_once "func.php";
require_once "test.php";
$obj = new \b\bb();
$obj->say();
- 重定向函数:
func.php
<?php
function redirect($namespace,$controller,$method){
$namespace = "\\".$namespace;
$controller = "\\".$controller;
$class = $namespace.$controller;
$obj = new $class();
$obj->$method();
}
- 需要的一些类:
class.php
<?php
namespace a;
class aa{
public function say(){
echo "a里面的方法";
}
}
namespace b;
class bb{
public function say(){
redirect('a','aa','say');
}
}
|