This question already has answers here:
Replace preg_replace() e modifier with preg_replace_callback
(3 answers)
Closed 2 years ago.
ErrorException [ 8192 ]: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead
on
http://mastersoftwaretechnologies.com/kohana/index.php/user/login
This works in my 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
Looks like you are using 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
With php 5.5 you should use preg_replace_callback()
Good example you will find here: Replace deprecated preg_replace /e with preg_replace_callback
And info how it works here: Replace preg_replace() e modifier with preg_replace_callback
Just modify second paremeter accordingly to that what you want to do with matches.
Related
This question already has answers here:
Replace preg_replace() e modifier with preg_replace_callback
(3 answers)
Closed 2 years ago.
i have this code
$read = preg_replace(array('/LANG\[([0-9]*?)\]/e','/URL\[([0-9]*?)\]/e'),array('get_words(\\1)','url(\\1)'),$read);
how to fix it using preg_replace_callback
The error message is telling you to remove the e modifier.
The e modifier is now removed/deprecated - https://www.php.net/manual/en/reference.pcre.pattern.modifiers.php
You can simply change the /e to /i to read this;
$read = preg_replace(array('/LANG\[([0-9]*?)\]/i','/URL\[([0-9]*?)\]/i'),array('get_words(\\1)','url(\\1)'),$read);
or remove the e completely to read this;
$read = preg_replace(array('/LANG\[([0-9]*?)\]/','/URL\[([0-9]*?)\]/'),array('get_words(\\1)','url(\\1)'),$read);
This question already has answers here:
Replace preg_replace() e modifier with preg_replace_callback
(3 answers)
Closed 5 years ago.
capitalize modifier in smarty throws error
{$payment.first_name|capitalize}
The above code throws the following error
Deprecated: preg_replace(): The /e modifier is deprecated, use
preg_replace_callback instead in
/home/mysuite/public_html/Demo/yoursite/includes/smarty/libs/plugins/modifier.capitalize.php
on line 65
You can use the php function ucwords like this.
{$payment.first_name|ucwords}
It might not work for non latin characters (not working on cyrillic) but than you can use some library and define your new function as smarty function.
This question already has answers here:
Replace preg_replace() e modifier with preg_replace_callback
(3 answers)
Closed 4 years ago.
function removeColorCode($text) {
return preg_replace('/\\^([0-9])/ie', '', $text);
}
The above code gives a deprecation warning on Echelon B3 i think after upgrading to PHP 5.5.29 by our host provider
How can I replace the code properly with preg_replace_callback()?
In this specific case, just remove the /e it does nothing here.
You can also remove the /i
So your code becomes:
function removeColorCode($text) {
return preg_replace('/\^[0-9]/', '', $text);
}
This question already has answers here:
Replace preg_replace() e modifier with preg_replace_callback
(3 answers)
Closed 7 years ago.
I'm trying to replace the following string:
\u0080\u009cone hand rule\u0080\u009d
As I have to replace those codes for many strings and as there are various combinations of \u0080\u009 like \u00e2\u0080\u0099 and \u00a0 I ve searched for an solution to convert them all back into their according value.
The solution i ve found was posted on this site: http://www.avoid.org/replace-u-characters-in-json-string/
preg_replace("/\\\\u([a-f0-9]{4})/e",
"iconv('UCS-4LE','UTF-8', pack('V', hexdec('U$1')))",
json_encode($struct));
As i was trying to use this code php threw the following error:
Deprecated: preg_replace(): The /e modifier is deprecated, use
preg_replace_callback instead
Since I'm relativley new to php i bareley understand the preg_replace in first place but with the conversion to preg_replace_callback i'm totally overstrained. I've looked up How to convert preg_replace e to preg_replace_callback? but i didnt get it :/
Could somone pls explain how to convert my preg_replace into preg_replace_callback?
The code I m trying to get to work looks now like this:
$string = preg_replace("/\\\\u([a-f0-9]{4})",
function($match){
return = iconv('UCS-4LE','UTF-8',pack('V', hexdec('U$1')), $match[1]);
},
json_encode($string));
I ve read and understood how to access my found matches but since the
"iconv('UCS-4LE','UTF-8', pack('V', hexdec('U$1')))",
from the original code doesnt access any of the matches found I'm quiet confused how to set up my anonymous function
As of PHP 5.5.0 E_DEPRECATED level error is emitted when passing in the "\e" modifier. As of PHP 7.0.0 E_WARNING is emited in this case and "\e" modifier has no effect.
Please visit preg_replace and preg_replace_callback for documentation
"/\\u([a-f0-9]{4})" = > "/\\u([a-f0-9]{4})/"
This question already has answers here:
How can I convert ereg expressions to preg in PHP?
(4 answers)
Closed 3 years ago.
I am getting the following error when running on PHP 5.3.8
Deprecated: Function eregi_replace() is deprecated in
/home/XXXXXX/public_html/admin/modifypoll.php on line 49
This is the line of code, can anyone help please
$question = eregi_replace('</?[a-z][a-z0-9]*[^<>]*>', '', $question );
I am not sure what to change it to.
Can anyone help please
the entire ereg family of functions are deprecated in PHP and will at some point be removed from the language. The replacement is the preg family. For the most part, the change is simple:
preg_replace('/[^<>]>/i', '', $question);
^-- ^ ^^
change ereg to preg
add delimeters (/)
for case insensitive matches (eregi), add the i modifier
$question = preg_replace('/<\/?[a-z][a-z0-9]*[^<>]*>/i', '', $question);
By the way, you can simply use $question = strip_tags($question); to achieve the same without any regexes!