MDL-60281 general: create_function is deprecated in PHP7.2

This commit is contained in:
Marina Glancy
2017-10-16 09:37:19 +08:00
parent 2abb1e888c
commit 484b43f456
17 changed files with 75 additions and 34 deletions
+9 -3
View File
@@ -560,8 +560,12 @@ class core_text {
static $callback2 = null ;
if (!$callback1 or !$callback2) {
$callback1 = create_function('$matches', 'return core_text::code2utf8(hexdec($matches[1]));');
$callback2 = create_function('$matches', 'return core_text::code2utf8($matches[1]);');
$callback1 = function($matches) {
return core_text::code2utf8(hexdec($matches[1]));
};
$callback2 = function($matches) {
return core_text::code2utf8($matches[1]);
};
}
$result = (string)$str;
@@ -600,7 +604,9 @@ class core_text {
if ($dec) {
if (!$callback) {
$callback = create_function('$matches', 'return \'&#\'.(hexdec($matches[1])).\';\';');
$callback = function($matches) {
return '&#' . hexdec($matches[1]) . ';';
};
}
$result = preg_replace_callback('/&#x([0-9a-f]+);/i', $callback, $result);
}