Update StringUtils.php

This commit is contained in:
Scott Arciszewski 2015-03-23 11:26:23 -04:00 committed by Fabien Potencier
parent 7221efc095
commit 76b36d385f
1 changed files with 8 additions and 1 deletions

View File

@ -72,7 +72,14 @@ class StringUtils
*/
public static function safeStrlen($string)
{
if (function_exists('mb_strlen')) {
// Premature optimization
// Since this cannot be changed at runtime, we can cache it
static $func_exists = null;
if ($func_exists === null) {
$func_exists = function_exists('mb_strlen');
}
if ($func_exists) {
return mb_strlen($string, '8bit');
}