3v4l.org

run code in 300+ PHP versions simultaneously
<?php function str_emoji($str){ function empic($h){ $p=dechex(str_replace(array('&#',';'),'',$h)); return '<img src="_POST[face]'.$p.'.png" alt="'.$h.'" class="smiley" />'; }; $str=preg_replace('#(\&\#[0-9]{6}\;)#ie','empic("\\1")',$str); return $str; }; $com_print=str_emoji('aaa&#128027;&#128013;bbb'); var_dump($com_print, empic(123));
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.4, 8.3.6
Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /in/cgQBa on line 8 NULL string(56) "<img src="_POST[face]7b.png" alt="123" class="smiley" />"
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /in/cgQBa on line 8 NULL string(56) "<img src="_POST[face]7b.png" alt="123" class="smiley" />"
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /in/cgQBa on line 8 string(136) "aaa<img src="_POST[face]1f41b.png" alt="&#128027;" class="smiley" /><img src="_POST[face]1f40d.png" alt="&#128013;" class="smiley" />bbb" string(56) "<img src="_POST[face]7b.png" alt="123" class="smiley" />"
Output for 5.4.0 - 5.4.45
string(136) "aaa<img src="_POST[face]1f41b.png" alt="&#128027;" class="smiley" /><img src="_POST[face]1f40d.png" alt="&#128013;" class="smiley" />bbb" string(56) "<img src="_POST[face]7b.png" alt="123" class="smiley" />"

preferences:
226.9 ms | 401 KiB | 376 Q