<?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('&', '&', $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";
}
preferences:
57 ms | 402 KiB | 5 Q