php 语法问题?
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');BASEPATH 指什么?
它是自定的variable吗? BASEPATH 是常量啊。
看看 PHP 手册 defined 函数的定义吧。
这句话的意思是防止非法访问当前的 PHP 文件。 BASEPATH 是在 index.php 中定义的。
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
这一句要求此文件必须通过index.php 调用执行。 BASEPATH 是在 index.php 中定义的。
Fanbin 发表于 2009-3-1 18:18 http://codeigniter.org.cn/forums/images/common/back.gif
是否只要在index.php定义了BASEPATH, 在其他page 加上 if ( ! defined('BASEPATH')) exit('No directscript access allowed');
就可以防止非法进入?
以前我是用session防止的, 不知道哪种较好? 对,只要加上 BASEPATH 就可以防止非法访问,只能从 index.php 访问了,呵呵。 恩恩 学到了:hug: 学习了{:1_1:} 这个存在于config.php里面,作用是外部访问只能通过index.php这个入口,保护其它文件的安全。BASEPATH就是index.php。我的理解
页:
[1]