3v4l.org

run code in 300+ PHP versions simultaneously
<?php $message = "输入法. 手写; 拼音; 关闭. 百科 文库 hao123 | 更多>> · 把百度设为主页把百度设为主页关于百度About Baidu. ©2014 Baidu 使用百度前必读 京ICP证030173号.";$end_html = 0;$start_html = 1;$tmp_message = '';$message = ' ' . $message . ' ';$html_entities_match = array('#&(?!(\#[0-9]+;))#', '#<#', '#>#');$html_entities_replace = array('&amp;', '&lt;', '&gt;');$html_on = 1; $bbcode_on = 1;$bbcode_uid = 1;$message = trim($message); if ($html_on) { $allowed_html_tags = split(',', $board_config['allow_html_tags']); $end_html = 0; $start_html = 1; $tmp_message = ''; $message = ' ' . $message . ' '; while ($start_html = strpos($message, '<', $start_html)) { $tmp_message .= preg_replace($html_entities_match, $html_entities_replace, substr($message, $end_html + 1, ($start_html - $end_html - 1))); if ($end_html = strpos($message, '>', $start_html)) { $length = $end_html - $start_html + 1; $hold_string = substr($message, $start_html, $length); if (($unclosed_open = strrpos(' ' . $hold_string, '<')) != 1) { $tmp_message .= preg_replace($html_entities_match, $html_entities_replace, substr($hold_string, 0, $unclosed_open - 1)); $hold_string = substr($hold_string, $unclosed_open - 1); } $tagallowed = false; for ($i = 0; $i < sizeof($allowed_html_tags); $i++) { $match_tag = trim($allowed_html_tags[$i]); if (preg_match('#^<\/?' . $match_tag . '[> ]#i', $hold_string)) { $tagallowed = (preg_match('#^<\/?' . $match_tag . ' .*?(style[ ]*?=|on[\w]+[ ]*?=)#i', $hold_string)) ? false : true; } } $tmp_message .= ($length && !$tagallowed) ? preg_replace($html_entities_match, $html_entities_replace, $hold_string) : $hold_string; $start_html += $length; } else { $tmp_message .= preg_replace($html_entities_match, $html_entities_replace, substr($message, $start_html, strlen($message))); $start_html = strlen($message); $end_html = $start_html; } } if ($end_html != strlen($message) && $tmp_message != '') { $tmp_message .= preg_replace($html_entities_match, $html_entities_replace, substr($message, $end_html + 1)); } $message = ($tmp_message != '') ? trim($tmp_message) : trim($message); } else { $message = preg_replace($html_entities_match, $html_entities_replace, $message); } // Decode the html entities for HTMLArea / TMEdit $message = str_replace('&amp;', '&', $message); $message = html_entity_decode($message); if($bbcode_on && $bbcode_uid != '') { $message = bbencode_first_pass($message, $bbcode_uid); } echo $message;

preferences:
36.07 ms | 405 KiB | 6 Q