简体   繁体   English

Database.php中的Kohana preg_replace错误

[英]Kohana preg_replace error in database.php

ErrorException [8192]:preg_replace():不建议使用/ e修饰符,而应在http://mastersoftwaretechnologies.com/kohana/index.php/user/login上使用preg_replace_callback

This works in my kohana-3.2 这在我的kohana-3.2

Replace 更换

$column = preg_replace('/"(.+?)"/e', '$this->quote_column("$1")', $column);

to

$column = preg_replace_callback('/"(.+?)"/', function($m) { return $this->quote_column($m[1]); }, $column);

In the file MODPATH/database/classes/kohana/database.php line 525 在文件MODPATH / database / classes / kohana / database.php第525行中

Looks like you are using php 5.5. 看来您使用的是PHP 5.5。 If you want to use preg replace eval with it you have to modify it firts because it is deprecated due to security reasons: http://php.net/manual/en/migration55.deprecated.php 如果要使用preg替换eval,则必须对其进行修改,因为它由于安全原因而被弃用: http ://php.net/manual/zh/migration55.deprecated.php

With php 5.5 you should use preg_replace_callback() 在PHP 5.5中,您应该使用preg_replace_callback()

Good example you will find here: Replace deprecated preg_replace /e with preg_replace_callback 您将在这里找到一个很好的例子: 用preg_replace_callback替换不赞成使用的preg_replace / e

And info how it works here: Replace preg_replace() e modifier with preg_replace_callback 并在此处了解其工作原理: 用preg_replace_callback替换preg_replace()e修饰符

Just modify second paremeter accordingly to that what you want to do with matches. 只需相应地修改第二个参数,即可进行匹配。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM