Home  >  Article  >  php教程  >  关于THINKPHP I函数的一些问题

关于THINKPHP I函数的一些问题

WBOY
WBOYOriginal
2016-06-07 11:39:171183browse

THINKPHP 的I函数 略微修改一下
Thinkphp 的I 函数非常强大, 自动 过滤和转义的功能我一直都在用, 不过有一些问题,就是 当php.ini配置文件'magic_quotes_gpc'选项 为ON 的时候,会多出一个 '\' 这样一个斜号,导致页面输出有问题
我今天查看了THINKPHP 3.1的源代码,它没有进行这个配置开关的判断,导致出现这个问题,那好办,写个判断方法就行了
在Thinkphp ThinkPHP\Common\functions.php 下写个这样的方法

function filter_stripslashes(&$value){<br>     // 去除斜杠<br>     if (get_magic_quotes_gpc()){//magic_quotes_gpc是否为ON<br>         $value = stripslashes($value);<br>     }<br> }然后在配置文件中 ThinkPHP\Conf\convention.php
中的选项添加这样一个配置'VAR_FILTERS'           =>  'filter_exp,filter_stripslashes',     // 全局系统变量的默认过滤方法 多个用逗号分割就大功告成,没有多出个斜杠了,输出也正常了

AD:真正免费,域名+虚机+企业邮箱=0元

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:thinkphp 精美404模板Next article:thinkphp3.2原创ajax分页