3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function utf8($num) { if($num<=0x7F) return chr($num); if($num<=0x7FF) return chr(($num>>6)+192).chr(($num&63)+128); if($num<=0xFFFF) return chr(($num>>12)+224).chr((($num>>6)&63)+128).chr(($num&63)+128); if($num<=0x1FFFFF) return chr(($num>>18)+240).chr((($num>>12)&63)+128).chr((($num>>6)&63)+128).chr(($num&63)+128); return ''; } function uniord($c) { $ord0 = ord($c{0}); if ($ord0>=0 && $ord0<=127) return $ord0; $ord1 = ord($c{1}); if ($ord0>=192 && $ord0<=223) return ($ord0-192)*64 + ($ord1-128); $ord2 = ord($c{2}); if ($ord0>=224 && $ord0<=239) return ($ord0-224)*4096 + ($ord1-128)*64 + ($ord2-128); $ord3 = ord($c{3}); if ($ord0>=240 && $ord0<=247) return ($ord0-240)*262144 + ($ord1-128)*4096 + ($ord2-128)*64 + ($ord3-128); return false; } //echo uniord('á'); 225 //echo utf8(0xE1); á //echo utf8(0x67); $strTest='Sali ¿te casarias conmigo?'; $new=''; for($i = 0, $n = mb_strlen($strTest); $i < $n; $i++) { $mbchar = mb_substr($strTest, $i, 1); //echo 'current char: '.$mbchar.' '; //echo 'uniord= '.uniord($mbchar).' '; //echo 'prev dec= '.(uniord($mbchar)+1).' '; //echo 'prev hex= '.dechex(uniord($mbchar)+1).' '; //echo 'prev char= '.utf8((uniord($mbchar)+1)).' - '; $new.=utf8((uniord($mbchar)+1)); } echo $new;//Tbmj!uf!dbtbsjbt!dponjhp@
Output for 5.6.8 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Tbmj!Àuf!dbtbsjbt!dponjhp@
Output for 5.2.10 - 5.5.35
Notice: Uninitialized string offset: 1 in /in/GFv0v on line 14 Notice: Uninitialized string offset: 1 in /in/GFv0v on line 14 Notice: Uninitialized string offset: 2 in /in/GFv0v on line 15 Notice: Uninitialized string offset: 3 in /in/GFv0v on line 16 Tbmj!uf!dbtbsjbt!dponjhp@
Output for 4.3.0 - 5.0.5, 5.1.1 - 5.2.9
Notice: Uninitialized string offset: 1 in /in/GFv0v on line 14 Notice: Uninitialized string offset: 1 in /in/GFv0v on line 14 Notice: Uninitialized string offset: 2 in /in/GFv0v on line 15 Notice: Uninitialized string offset: 3 in /in/GFv0v on line 16 Tbmj!uf!dbtbsjbt!dponjhp@
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/GFv0v on line 34
Process exited with code 255.