CodeIgniter BASEPATH [英] CodeIgniter BASEPATH

查看:54
本文介绍了CodeIgniter BASEPATH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆