if ( ! defined('BASEPATH')) exit('No direct script access allowed')的作用
2017-02-13 09:42
337 查看
在看源代码时,发现codeigniter框架的控制器中,总是加上这样一段话;
if(!defined('BASEPATH'))exit('No
direct script access allowed');
刚接触codeigniter,一直没有领会它的作用,后来通过查资料发现其作用是:
为了防止跨站攻击,直接通过访问文件路径用的
另外要注意,这里定义的是:defined()而不是define(),如果你误将defined写成define,将会报一下错误:
A
PHP Error was encounteredSeverity:
WarningMessage:
define() expects at least 2
parameters, 1
given
if(!defined('BASEPATH'))exit('No
direct script access allowed');
刚接触codeigniter,一直没有领会它的作用,后来通过查资料发现其作用是:
为了防止跨站攻击,直接通过访问文件路径用的
另外要注意,这里定义的是:defined()而不是define(),如果你误将defined写成define,将会报一下错误:
A
PHP Error was encounteredSeverity:
WarningMessage:
define() expects at least 2
parameters, 1
given
相关文章推荐
- if ( ! defined('BASEPATH')) exit('No direct script access allowed')的作用
- defined('BASEPATH') OR exit('No direct script access allowed'); 的作用
- if ( ! defined('BASEPATH')) exit('No direct script access allowed')的作用
- [C++]#if !defined 的作用
- 2013-10-1目前版本下TinyOS下载遇到问题:Uploading to MICAZ: Direct Parallel Access not defined
- no internet access even if wifi connected success
- 织梦的if(!defined('DEDEINC')) exit("Request Error!");解析
- 未知的系统错误(The transaction is no longer active - status: 'Committed'. No further JDBC access is allowed within this transaction.)
- ajax跨域获取php文件数据报错:No 'Access-Control-Allow-Origin' header is present on the requested resource.”
- ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
- #1045 - Access denied for user 'root'@'localhost' (using password: NO)
- Linux MySQL修改密码时 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
- HTTP Status 404 - No result defined for action EmployeeAction and result input - struts2类似异常解决及原因剖析
- solr no operations allowed after connection closed
- 解决MySQL 报错:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
- checking for pg_config... no No pg_config... trying anyway. If building fails, please try again with
- Request header field attachmentdata is not allowed by Access-Control-Allow-Headers in preflight resp
- com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed. 解决
- No 'Access-Control-Allow-Origin' header is present on the requested resource
- [INS-40724] No locally defined network interface matches the SCAN VIP subnet