是否可以在PHP中使用函数包含文件?我已经尝试了一些东西,但该文件未包含在脚本中。PHP通过函数包含文件
我使用这个功能:
function run($entry_point){
if(!empty($entry_point)){
if(file_exists('assets/controllers/'.$entry_point.'.php'))
include 'assets/controllers/'.$entry_point.'.php';
else
include 'assets/controllers/home.php';
}
}
我的问题了,随着这种功能的指标将不包括$entry_point
文件。
Index.php
代码:
session_start();
run($_GET['location']);
谢谢!
'是否可以在PHP中使用函数包含文件?'是 – MonkeyZeus
“*如果包含在调用文件中的函数内发生,则包含在调用文件中的所有代码将表现得好像它具有被定义在该函数中。*“[源](http://php.net/manual/en/function.include.php) – Frxstrem
好的,所以它有一个更干净的方式来做到这一点? –