3v4l.org

run code in 300+ PHP versions simultaneously
<?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); á $strTest='holá'; for($i = 0, $n = mb_strlen($strTest); $i < $n; $i++) { $mbchar = mb_substr($strUTF8, $i, 1); echo 'current char: '.$mbchar.'\n<br\>'; echo 'uniord= '.uniord($mbchar).'\n<br\>'; echo 'prev char= '.utf8(dechex(uniord($mbchar)-1)).'\n<br\>'.'\n<br\>'; }
Output for 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: Array and string offset access syntax with curly braces is no longer supported in /in/3U2Sq on line 13
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Deprecated: Array and string offset access syntax with curly braces is deprecated in /in/3U2Sq on line 13 Deprecated: Array and string offset access syntax with curly braces is deprecated in /in/3U2Sq on line 14 Deprecated: Array and string offset access syntax with curly braces is deprecated in /in/3U2Sq on line 15 Deprecated: Array and string offset access syntax with curly braces is deprecated in /in/3U2Sq on line 16 Notice: Undefined variable: strUTF8 in /in/3U2Sq on line 23 current char: \n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 uniord= 0\n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 Warning: chr() expects parameter 1 to be int, string given in /in/3U2Sq on line 4 prev char= \n<br\>\n<br\> Notice: Undefined variable: strUTF8 in /in/3U2Sq on line 23 current char: \n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 uniord= 0\n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 Warning: chr() expects parameter 1 to be int, string given in /in/3U2Sq on line 4 prev char= \n<br\>\n<br\> Notice: Undefined variable: strUTF8 in /in/3U2Sq on line 23 current char: \n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 uniord= 0\n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 Warning: chr() expects parameter 1 to be int, string given in /in/3U2Sq on line 4 prev char= \n<br\>\n<br\> Notice: Undefined variable: strUTF8 in /in/3U2Sq on line 23 current char: \n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 uniord= 0\n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 Warning: chr() expects parameter 1 to be int, string given in /in/3U2Sq on line 4 prev char= \n<br\>\n<br\>
Output for 7.3.32 - 7.3.33
current char: \n<br\>uniord= 0\n<br\>prev char= \n<br\>\n<br\>current char: \n<br\>uniord= 0\n<br\>prev char= \n<br\>\n<br\>current char: \n<br\>uniord= 0\n<br\>prev char= \n<br\>\n<br\>current char: \n<br\>uniord= 0\n<br\>prev char= \n<br\>\n<br\>
Output for 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.10, 7.2.0 - 7.2.33, 7.3.12 - 7.3.31
Notice: Undefined variable: strUTF8 in /in/3U2Sq on line 23 current char: \n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 uniord= 0\n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 prev char= \n<br\>\n<br\> Notice: Undefined variable: strUTF8 in /in/3U2Sq on line 23 current char: \n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 uniord= 0\n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 prev char= \n<br\>\n<br\> Notice: Undefined variable: strUTF8 in /in/3U2Sq on line 23 current char: \n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 uniord= 0\n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 prev char= \n<br\>\n<br\> Notice: Undefined variable: strUTF8 in /in/3U2Sq on line 23 current char: \n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 uniord= 0\n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 prev char= \n<br\>\n<br\>
Output for 5.2.10 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35
Notice: Undefined variable: strUTF8 in /in/3U2Sq on line 23 current char: \n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 uniord= 0\n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 prev char= \n<br\>\n<br\> Notice: Undefined variable: strUTF8 in /in/3U2Sq on line 23 current char: \n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 uniord= 0\n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 prev char= \n<br\>\n<br\> Notice: Undefined variable: strUTF8 in /in/3U2Sq on line 23 current char: \n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 uniord= 0\n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 prev char= \n<br\>\n<br\> Notice: Undefined variable: strUTF8 in /in/3U2Sq on line 23 current char: \n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 uniord= 0\n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 prev char= \n<br\>\n<br\> Notice: Undefined variable: strUTF8 in /in/3U2Sq on line 23 current char: \n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 uniord= 0\n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 prev char= \n<br\>\n<br\>
Output for 5.0.4 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.9
Notice: Undefined variable: strUTF8 in /in/3U2Sq on line 23 current char: \n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 uniord= 0\n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 prev char= \n<br\>\n<br\> Notice: Undefined variable: strUTF8 in /in/3U2Sq on line 23 current char: \n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 uniord= 0\n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 prev char= \n<br\>\n<br\> Notice: Undefined variable: strUTF8 in /in/3U2Sq on line 23 current char: \n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 uniord= 0\n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 prev char= \n<br\>\n<br\> Notice: Undefined variable: strUTF8 in /in/3U2Sq on line 23 current char: \n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 uniord= 0\n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 prev char= \n<br\>\n<br\> Notice: Undefined variable: strUTF8 in /in/3U2Sq on line 23 current char: \n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 uniord= 0\n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 prev char= \n<br\>\n<br\>
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.3
Notice: Undefined variable: strUTF8 in /in/3U2Sq on line 23 current char: \n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 uniord= 0\n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 prev char= \n<br\>\n<br\> Notice: Undefined variable: strUTF8 in /in/3U2Sq on line 23 current char: \n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 uniord= 0\n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 prev char= \n<br\>\n<br\> Notice: Undefined variable: strUTF8 in /in/3U2Sq on line 23 current char: \n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 uniord= 0\n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 prev char= \n<br\>\n<br\> Notice: Undefined variable: strUTF8 in /in/3U2Sq on line 23 current char: \n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 uniord= 0\n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 prev char= \n<br\>\n<br\> Notice: Undefined variable: strUTF8 in /in/3U2Sq on line 23 current char: \n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 uniord= 0\n<br\> Notice: Uninitialized string offset: 0 in /in/3U2Sq on line 13 prev char= \n<br\>\n<br\>

preferences:
239.25 ms | 405 KiB | 312 Q