我是Codeigniter的新手。据我对 BASEPATH 的了解,它用于激活Codeigniter框架。代码
Hi I am new to Codeigniter. From my understanding of the BASEPATH, it is used to activate the Codeigniter framework. The code
defined('BASEPATH') OR exit('No direct script access allowed');来防止直接访问控制器。但这在我的代码中不起作用。当我尝试通过控制器直接访问视图时,将加载该视图。我检查了 index.php 并在其中定义了 BASEPATH 。
is used at top of the page to prevent direct access to the controller. But it is not working in my code. When I try to directly access a view via controller, the view gets loaded. I have checked index.php and BASEPATH is defined there. Please advice.
推荐答案defined('BASEPATH')或exit('不允许直接脚本访问' ); 用于确保请求已通过根目录中的 index.php 进行了处理。这是由于诸如确保已加载所有Codeigniter基类以及确保已设置某些变量等原因。
defined('BASEPATH') OR exit('No direct script access allowed'); is used to make sure that the request has gone through index.php in your root dir. This is for reasons such as making sure that all Codeigniter base classes are being loaded and making sure certain vars have been set etc.
因此,是的,您将能够访问视图文件(如果要通过控制器)。
So, yes you will be able to access a view file if you're going through a controller.
希望这会有所帮助!
更多推荐
CodeIgniter BASEPATH
发布评论