* Fix bug for php7.2.

This commit is contained in:
滔哥
2018-08-08 19:29:51 +08:00
parent e295fd0203
commit c8a78acbb9
2 changed files with 14 additions and 2 deletions
+3 -1
View File
@@ -170,10 +170,12 @@ function formatTime($time, $format = '')
* @access protected
* @return void
*/
function __autoload($class)
function autoloader($class)
{
if(!class_exists($class))
{
if($class == 'post_max_size' or $class == 'max_input_vars') eval('class ' . $class . ' {};');
}
}
spl_autoload_register('autoloader');
+11 -1
View File
@@ -43,7 +43,17 @@ class pinyin
*/
public function prepare($string)
{
$string = preg_replace_callback('/[a-z0-9_-]+/i', create_function('$matches', 'return "\t" . $matches[0];'), $string);
if(version_compare(PHP_VERSION, '7.2.0') >= 0)
{
$string = preg_replace_callback('/[a-z0-9_-]+/i', function($matches)
{
return "\t" . $matches[0];
}, $string);
}
else
{
$string = preg_replace_callback('/[a-z0-9_-]+/i', create_function('$matches', 'return "\t" . $matches[0];'), $string);
}
return preg_replace("/[^\p{Han}\p{P}\p{Z}\p{M}\p{N}\p{L}\t]/u", '', $string);
}