`

codeigniter搭配php 5.3中两个值得注意的问题

    博客分类:
  • PHP
PHP 
阅读更多
codegniter 1.7跟PHP5。3配合时,有些地方要改下的,主要是php 5.3有不少跟php 5.2不同的地方了,要特别留意下,

1 PHP:Deprecated: Function set_magic_quotes_runtime() is deprecated 错误:
  PHP5.3和PHP6.0之后移除了set_magic_quotes_runtime()函数。

set_magic_quotes_runtime(0)函数作用解释
在php.ini的配置文件中,有个布尔值的设置,就是magic_quotes_runtime,当它打开时,php的大部分函数自动的给从外部引入的(包括数据库或者文件)数据中的溢出字符加上反斜线。

当然如果重复给溢出字符加反斜线,那么字符串中就会有多个反斜线,所以这时就要用set_magic_quotes_runtime()与 get_magic_quotes_runtime()设置和检测php.ini文件中magic_quotes_runtime状态。

为了使自己的程序不管服务器是什么设置都能正常执行。可以在程序开始用get_magic_quotes_runtime检测设置状态秋决定是否要手工处理,或者在开始(或不需要自动转义的时候)用set_magic_quotes_runtime(0)关掉。

magic_quotes_gpc设置是否自动为GPC(get,post,cookie)传来的数据中的'"\加上反斜线。可以用 get_magic_quotes_gpc()检测系统设置。如果没有打开这项设置,可以使用addslashes()函数添加,它的功能就是给数据库查询语句等的需要在某些字符前加上了反斜线。这些字符是单引号(')、双引号(")、反斜线(\)与 NUL(NULL 字符)。


解决办法:

//@set_magic_quotes_runtime(0);

ini_set("magic_quotes_runtime",0);

就是用ini_set()办法替代原有的set_magic_quotes_runtime语法。



2  “The URI you submitted has disallowed characters.” error CodeIgniter
1) in codeigiter system/libraries open  URI.php  line 189 you’ll find

if ( ! preg_match("|^[".preg_quote($this->config->item('permitted_uri_chars'))."]+$|i", rawurlencode($str)))

Change that to:

if ( ! preg_match("|^[".($this->config->item('permitted_uri_chars'))."]+$|i", rawurlencode($str)))

Note we removed the preg_quote().  Now in your system/application/config/config.php file  look for line 126 (unless you’ve added a lot to you config will be around there somewhere)

Change the line

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_-';

to:

$config['permitted_uri_chars'] = 'a-z 0-9~%\.\:_\-';


3 php5.3开始后,废除了php中的”=&”符号,所以要想复制,直接用=引用即可。
比如:
  freakauth_light = & new MyFAL();
改为 $obj->freakauth_light =  new MyFAL();
1
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics