CodeIgniter BASEPATH

编程入门 行业动态 更新时间:2024-10-17 23:23:21
本文介绍了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

本文发布于:2023-11-16 14:34:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1605158.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:CodeIgniter   BASEPATH

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!