为啥控制器这么听话
程序员文章站
2022-05-30 11:25:10
...
phpcms中
header('location:index.php?m=admin');用m就能控制入口进入哪个模块中,比如m=admin进入admin模块,m=abc就能进入 abc模块执行其中的命令,那么这是怎么玩的呢
别说大道理,大道理都明白,我要的是细节
private function load_controller($filename = "', $m = '') {
if (emptyempty($filename)) $filename = ROUTE_C;
if (emptyempty($m)) $m = ROUTE_M;
$filepath = PC_PATH.'modules'.DIRECTORY_SEPARATOR.$m.DIRECTORY_SEPARATOR.$filename.'.php';
if (file_exists($filepath)) {
$classname = $filename;
include $filepath;
if ($mypath = pc_base::my_path($filepath)) {
$classname = 'MY_'.$filename;
include $mypath;
}
if(class_exists($classname)){
return new $classname;
}else{
exit('Controller does not exist.');
}
} else {
exit('Controller does not exist.');
}
}
这怎么解释呢,如果你还想来大道理,请看别人回帖吧
别说大道理,大道理都明白,我要的是细节
private function load_controller($filename = "', $m = '') {
if (emptyempty($filename)) $filename = ROUTE_C;
if (emptyempty($m)) $m = ROUTE_M;
$filepath = PC_PATH.'modules'.DIRECTORY_SEPARATOR.$m.DIRECTORY_SEPARATOR.$filename.'.php';
if (file_exists($filepath)) {
$classname = $filename;
include $filepath;
if ($mypath = pc_base::my_path($filepath)) {
$classname = 'MY_'.$filename;
include $mypath;
}
if(class_exists($classname)){
return new $classname;
}else{
exit('Controller does not exist.');
}
} else {
exit('Controller does not exist.');
}
}
这怎么解释呢,如果你还想来大道理,请看别人回帖吧
呵呵,这么明显的代码,细节是英文字母?
header('location:index.php?m=admin');用m就能控制入口进入哪个模块中,比如m=admin进入admin模块,m=abc就能进入 abc模块执行其中的命令,那么这是怎么玩的呢
回复讨论(解决方案)
自然是做了相应的跳转。这是一般框架和cms系统都有的路由功能。
自然是做了相应的跳转。这是一般框架和cms系统都有的路由功能。
别说大道理,大道理都明白,我要的是细节
private function load_controller($filename = "', $m = '') {
if (emptyempty($filename)) $filename = ROUTE_C;
if (emptyempty($m)) $m = ROUTE_M;
$filepath = PC_PATH.'modules'.DIRECTORY_SEPARATOR.$m.DIRECTORY_SEPARATOR.$filename.'.php';
if (file_exists($filepath)) {
$classname = $filename;
include $filepath;
if ($mypath = pc_base::my_path($filepath)) {
$classname = 'MY_'.$filename;
include $mypath;
}
if(class_exists($classname)){
return new $classname;
}else{
exit('Controller does not exist.');
}
} else {
exit('Controller does not exist.');
}
}
这怎么解释呢,如果你还想来大道理,请看别人回帖吧
自然是做了相应的跳转。这是一般框架和cms系统都有的路由功能。
别说大道理,大道理都明白,我要的是细节
private function load_controller($filename = "', $m = '') {
if (emptyempty($filename)) $filename = ROUTE_C;
if (emptyempty($m)) $m = ROUTE_M;
$filepath = PC_PATH.'modules'.DIRECTORY_SEPARATOR.$m.DIRECTORY_SEPARATOR.$filename.'.php';
if (file_exists($filepath)) {
$classname = $filename;
include $filepath;
if ($mypath = pc_base::my_path($filepath)) {
$classname = 'MY_'.$filename;
include $mypath;
}
if(class_exists($classname)){
return new $classname;
}else{
exit('Controller does not exist.');
}
} else {
exit('Controller does not exist.');
}
}
这怎么解释呢,如果你还想来大道理,请看别人回帖吧
呵呵,这么明显的代码,细节是英文字母?
脾气不小啊啊
$filepath = PC_PATH.'modules'.DIRECTORY_SEPARATOR.$m.DIRECTORY_SEPARATOR.$filename.'.php';
组织文件路径
include $filepath;
引入文件
这么明显了....你要是include 都不知道...没办法
上一篇: 为PHP函数执行设置超时