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(',', array('<b>', '</b>')); $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;
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught Error: Call to undefined function split() in /in/PKTt5:3 Stack trace: #0 {main} thrown in /in/PKTt5 on line 3
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Deprecated: Function split() is deprecated in /in/PKTt5 on line 3 Warning: split() expects parameter 2 to be string, array given in /in/PKTt5 on line 3
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.1 - 5.1.6, 5.2.0 - 5.2.17
Notice: Array to string conversion in /in/PKTt5 on line 3
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/PKTt5 on line 3
Process exited with code 255.

preferences:
275.88 ms | 401 KiB | 459 Q