-1

I board a small mistake I notice used to solve just by changing preg_replace preg_replace_callback put his put me another error that I board not understand if someone would have the privilege to explain the error I thank in advance.

here is the error

Warning: preg_replace_callback(): Requires argument 2, 'stripslashes('\1').mb_convert_case(stripslashes('\2'),MB_CASE_UPPER, 'UTF-8')', to be a valid callback in /htdocs/system/ext/Smarty/libs/plugins/modifier.capitalize.php on line 33
Warning: preg_replace_callback(): Requires argument 2, 'stripslashes('\1').mb_convert_case(stripslashes('\3'),MB_CASE_UPPER, 'UTF-8')', to be a valid callback in /htdocs/system/ext/Smarty/libs/plugins/modifier.capitalize.php on line 43

line 33

$upper_string = preg_replace_callback("!(^|[^\p{L}'])([\p{Ll}])!eS" . Smarty::$_UTF8_MODIFIER, "stripslashes('\\1').mb_convert_case(stripslashes('\\2'),MB_CASE_UPPER, '" . addslashes(Smarty::$_CHARSET) . "')", $string);
    }

line 43

$upper_string = preg_replace_callback("!((^|\s)['\"])(\w)!e" . Smarty::$_UTF8_MODIFIER, "stripslashes('\\1').mb_convert_case(stripslashes('\\3'),MB_CASE_UPPER, '" . addslashes(Smarty::$_CHARSET) . "')", $upper_string);
       return $upper_string;
   }

Thank you

DavidDomain
  • 14,976
  • 4
  • 42
  • 50
roow
  • 7
  • 1

1 Answers1

1

I'm afraid you cannot use any expression as callback, but a REAL function name, not a whole expression like "stripslashes('\1').mb_convert_case(stripslashes('\2'),MB_CASE_UPPER, 'UTF-8')"

You can also pass a WHOLE function as the parameter...

I know it's a pain to look at documentation, but I cannot explain it better than it is in here

You should use it like this:

$closure = function($match){
        return $match[0].stripslashes('\1').mb_convert_case(stripslashes('\2'),MB_CASE_UPPER, 'UTF-8');
    } ;
$upper_string = preg_replace_callback(
    "!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER,
    $closure
    ,
    $url);

Notice I removed the "e" regexp search modifier because... well, because it's useless and deprecated, but feel free to add it again at the end of regexp and experiment with the errors

Amarnasan
  • 14,939
  • 5
  • 33
  • 37