3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $test_str = "I&#039;ll"; function setup_functions(){ global $smcFunc; $smcFunc = array(); $utf8=1; $ent_list = '&(#\d{1,7}|quot|amp|lt|gt|nbsp);'; $ent_check = array('preg_replace(\'~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~e\', \'$smcFunc[\\\'entity_fix\\\'](\\\'\\2\\\')\', ', ')'); $smcFunc += array( 'entity_fix' => create_function('$string', ' $num = substr($string, 0, 1) === \'x\' ? hexdec(substr($string, 1)) : (int) $string; return $num < 0x20 || $num > 0x10FFFF || ($num >= 0xD800 && $num <= 0xDFFF) || $num === 0x202E || $num === 0x202D ? \'\' : \'&#\' . $num . \';\';'), 'strlen' => create_function('$string', ' global $smcFunc; return strlen(preg_replace(\'~' . $ent_list . '|.~u' . '\', \'_\', ' . implode('$string', $ent_check) . '));') ); } setup_functions(); echo "Length = " . $smcFunc['strlen']($test_str) . "\n"; ?>
Output for 7.0.0 - 7.1.0
Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /in/7vgnr(18) : runtime-created function on line 3 Length = 0
Output for 5.5.24 - 5.6.28
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /in/7vgnr(18) : runtime-created function on line 3 Length = 4
Output for 4.3.0 - 5.4.45
Length = 4