3v4l.org

run code in 300+ PHP versions simultaneously
<?php function a($strUrl) { $strUrl = explode('/', $strUrl, 4); $strUrl[3] = rawurlencode($strUrl[3]); $strUrl[3] = str_replace(array('%2F', '%3F', '%3D', '%26', '%25'), array('/', '?', '=', '&', '%'), $strUrl[3]); $strUrl = implode('/', $strUrl); $strUrl = str_replace('&', '&amp;', $strUrl); return $strUrl; } function b($strUrl) { return htmlspecialchars($strUrl, ENT_XML1, 'UTF-8'); } $urls = array( 'http://www.example.com/', 'http://www.example.com/alias', 'http://www.example.com/alias.html', 'http://www.example.com/alias/page?foo=bar', 'http://www.example.com/alias?foo=bar&bar=foo', 'http://www.example.com:8080/alias', 'http://www.example.com:8080/alias?foo=bar&bar[bar]=foo', 'http://www.example.com/älias', ); foreach ($urls as $url) { if (a($url) === b($url)) { echo "✓\n"; echo $url."\n"; } else { echo "✘\n"; echo $url."\n"; echo a($url)."\n"; echo b($url)."\n"; } echo "\n"; }
Output for 7.1.0 - 7.1.25, 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
✓ http://www.example.com/ ✓ http://www.example.com/alias ✓ http://www.example.com/alias.html ✓ http://www.example.com/alias/page?foo=bar ✓ http://www.example.com/alias?foo=bar&bar=foo ✓ http://www.example.com:8080/alias ✘ http://www.example.com:8080/alias?foo=bar&bar[bar]=foo http://www.example.com:8080/alias?foo=bar&amp;bar%5Bbar%5D=foo http://www.example.com:8080/alias?foo=bar&amp;bar[bar]=foo ✘ http://www.example.com/älias http://www.example.com/%C3%A4lias http://www.example.com/älias
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 ✓ http://www.example.com/ ✓ http://www.example.com/alias ✓ http://www.example.com/alias.html ✓ http://www.example.com/alias/page?foo=bar ✓ http://www.example.com/alias?foo=bar&bar=foo ✓ http://www.example.com:8080/alias ✘ http://www.example.com:8080/alias?foo=bar&bar[bar]=foo http://www.example.com:8080/alias?foo=bar&amp;bar%5Bbar%5D=foo http://www.example.com:8080/alias?foo=bar&amp;bar[bar]=foo ✘ http://www.example.com/älias http://www.example.com/%C3%A4lias http://www.example.com/älias

preferences:
149.46 ms | 402 KiB | 171 Q