Answer the question
In order to leave comments, you need to log in
Calling a specific function on php 5.2.17 under OS X gives an empty response to the browser. Why?
The function is like this:
function strip_nonUtf8($str) {
static $fourbytes = '[\n\t\r\x20-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xef][\x80-\xbf][\x80-\xbf]|\xf0[\x90-\xbf][\x80-\xbf][\x80-\xbf]|[\xf1-\xf7][\x80-\xbf][\x80-\xbf][\x80-\xbf]';
$result = '';
while (strlen($str) > 2000) {
if (!preg_match("/^($fourbytes){100}/", $str, $match)) {
if (preg_match("/^($fourbytes)*/", $str, $match)) {
$result .= $match[0];
$str = substr($str, strlen($match[0]));
}
// now the first character is bad
$str = substr($str, 1);
continue;
}
$result .= $match[0];
$str = substr($str, strlen($match[0]));
}
if ($str != '' && preg_match_all("/($fourbytes)+/", $str, $matches, PREG_PATTERN_ORDER)) {
$result .= join('', $matches[0]);
}
$result = strip_tags($result);
return $result;
}
Answer the question
In order to leave comments, you need to log in
This is not a browser issue. I gave the Chrome error as an example of an empty response from a web server.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question