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(',', '<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;

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
5.4.310.0070.03712.50
5.4.300.0070.03412.50
5.4.290.0080.03512.49
5.4.280.0030.03712.39
5.4.270.0050.03712.39
5.4.260.0040.03812.39
5.4.250.0030.04012.39
5.4.240.0070.03412.39
5.4.230.0030.04012.39
5.4.220.0050.03712.39
5.4.210.0050.03612.38
5.4.200.0060.03712.38
5.4.190.0060.03512.38
5.4.180.0060.03512.38
5.4.170.0080.03412.39
5.4.160.0050.03712.38
5.4.150.0040.03812.38
5.4.140.0070.03512.07
5.4.130.0060.03512.05
5.4.120.0030.03912.02
5.4.110.0060.03512.02
5.4.100.0050.03512.02
5.4.90.0050.03712.02
5.4.80.0070.03612.01
5.4.70.0060.03412.01
5.4.60.0070.03412.01
5.4.50.0060.03412.01
5.4.40.0060.03412.00
5.4.30.0050.03611.99
5.4.20.0100.03012.00
5.4.10.0060.03911.99
5.4.00.0060.03511.49
5.3.280.0080.03512.71
5.3.270.0080.03612.73
5.3.260.0100.03412.72
5.3.250.0060.03712.72
5.3.240.0030.03912.72
5.3.230.0070.03612.71
5.3.220.0040.03812.68
5.3.210.0050.03912.68
5.3.200.0070.03512.68
5.3.190.0040.03912.68
5.3.180.0050.03612.68
5.3.170.0030.04112.67
5.3.160.0070.03412.68
5.3.150.0060.03612.68
5.3.140.0070.03512.66
5.3.130.0060.03812.66
5.3.120.0060.03812.66
5.3.110.0090.03512.66
5.3.100.0070.03512.12
5.3.90.0030.03912.08
5.3.80.0060.03612.07
5.3.70.0030.03812.07
5.3.60.0070.03512.06
5.3.50.0060.03512.00
5.3.40.0030.03912.00
5.3.30.0090.03111.95
5.3.20.0060.03411.73
5.3.10.0040.03611.70
5.3.00.0070.03411.69
5.2.170.0040.0309.19
5.2.160.0050.0289.18
5.2.150.0040.0309.19
5.2.140.0030.0329.18
5.2.130.0050.0289.14
5.2.120.0020.0309.15
5.2.110.0060.0279.15
5.2.100.0020.0309.15
5.2.90.0030.0299.15
5.2.80.0030.0319.14
5.2.70.0060.0289.14
5.2.60.0040.0309.09
5.2.50.0030.0319.07
5.2.40.0040.0299.05
5.2.30.0020.0329.02
5.2.20.0040.0289.01
5.2.10.0020.0308.93
5.2.00.0060.0278.79
5.1.60.0040.0238.08
5.1.50.0030.0258.07
5.1.40.0070.0228.05
5.1.30.0000.0298.40
5.1.20.0040.0268.43
5.1.10.0040.0268.15
5.1.00.0030.0268.15
5.0.50.0040.0206.63
5.0.40.0030.0196.49
5.0.30.0020.0326.30
5.0.20.0070.0156.27
5.0.10.0010.0226.25
5.0.00.0030.0346.24
4.4.90.0020.0164.78
4.4.80.0020.0164.75
4.4.70.0030.0184.75
4.4.60.0030.0154.75
4.4.50.0030.0164.77
4.4.40.0020.0254.71
4.4.30.0030.0154.76
4.4.20.0040.0144.84
4.4.10.0030.0154.85
4.4.00.0030.0254.75
4.3.110.0060.0134.67
4.3.100.0010.0174.66
4.3.90.0020.0154.63
4.3.80.0020.0254.58
4.3.70.0020.0194.63
4.3.60.0010.0174.63
4.3.50.0020.0164.63
4.3.40.0020.0244.54
4.3.30.0040.0143.29
4.3.20.0010.0173.27
4.3.10.0030.0153.23
4.3.00.0170.01715.29

preferences:
138.12 ms | 1398 KiB | 7 Q