3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @link https://stackoverflow.com/a/10042586/367456 * @param string $string unicode and ulrencoded string * @return string decoded string */ function utf8_urldecode($string) { $string = preg_replace( "/%u([0-9a-f]{3,4})/i", "&#x\\1;", urldecode($string) ); return html_entity_decode($string, ENT_XML1, 'UTF-8'); } $decoded = utf8_urldecode('%u20AC'); class_exists('IntlChar') && printf("U+%X %s\n", IntlChar::ord($decoded), IntlChar::charName($decoded)); echo "\\x" . implode("\\x", str_split(strtoupper(bin2hex($decoded)), 2)), "\n"; echo addcslashes($decoded, "\x7F..\xFF"), "\n";
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.32, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
U+20AC EURO SIGN \xE2\x82\xAC \342\202\254
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.4.33
\xE2\x82\xAC \342\202\254
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Notice: Use of undefined constant ENT_XML1 - assumed 'ENT_XML1' in /in/5bUMS on line 14 Warning: html_entity_decode() expects parameter 2 to be long, string given in /in/5bUMS on line 14 \x
Output for 4.4.5 - 4.4.9
Notice: Use of undefined constant ENT_XML1 - assumed 'ENT_XML1' in /in/5bUMS on line 14 Warning: html_entity_decode() expects parameter 2 to be long, string given in /in/5bUMS on line 14 Fatal error: Call to undefined function: str_split() in /in/5bUMS on line 19
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
Notice: Use of undefined constant ENT_XML1 - assumed 'ENT_XML1' in /in/5bUMS on line 14 Warning: html_entity_decode() expects parameter 2 to be long, string given in /in/5bUMS on line 14 Fatal error: Call to undefined function: str_split() in /in/5bUMS on line 19
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Notice: Use of undefined constant ENT_XML1 - assumed 'ENT_XML1' in /in/5bUMS on line 14 Warning: html_entity_decode() expects parameter 2 to be long, string given in /in/5bUMS on line 14 Fatal error: Call to undefined function: str_split() in /in/5bUMS on line 19

preferences:
140.84 ms | 412 KiB | 5 Q