54 public static function getSubstring($str, $start, $length, $encoding =
null)
60 $encoding = Main\Localization\Translation::getCurrentEncoding();
62 return \mb_substr($str, $start, $length, $encoding);
65 return \substr($str, $start, $length);
76 public static function getPosition($haystack, $needle, $offset = 0, $encoding =
null)
78 if (\function_exists(
'mb_strpos'))
82 $encoding = Main\Localization\Translation::getCurrentEncoding();
84 return \mb_strpos($haystack, $needle, $offset, $encoding);
87 return \strpos($haystack, $needle, $offset);
139 if (empty($encoding))
141 $encoding = Main\Localization\Translation::getCurrentEncoding();
143 return \htmlspecialchars($string, $flags, $encoding,
true);
238 if (!empty($str) && is_string($str))
240 if ($enclosure ==
'<<<')
242 $validTokens = [\T_CONSTANT_ENCAPSED_STRING, \T_START_HEREDOC, \T_ENCAPSED_AND_WHITESPACE, \T_END_HEREDOC];
244 $tokens = \token_get_all(
'<'.
"?php \$MESS = <<<'HTML'\n". $str.
"\nHTML;");
248 $validTokens = [\T_CONSTANT_ENCAPSED_STRING];
249 $validChars = [$enclosure];
250 $tokens = \token_get_all(
'<'.
'?php $MESS = '. $enclosure. $str. $enclosure .
';');
252 $cnt = count($tokens);
253 if ($cnt <= 5 || $cnt > 10)
258 for ($inx = 5, $cnt--; $inx < $cnt ; $inx++)
260 $token = $tokens[$inx];
261 if (is_array($token))
263 $token[] = \token_name($token[0]);
264 if (!in_array($token[0], $validTokens))
270 elseif (is_string($token))
272 if (!in_array($token, $validChars))