$url = 'https://example.com/my-page?param=value'; $cleanUrl = t3lib_div::sanitizeLocalUrl($url); echo $cleanUrl;
https://example.com/my-page?param=value
$url = 'javascript:alert(\'Hello world!\');'; $cleanUrl = t3lib_div::sanitizeLocalUrl($url); echo $cleanUrl;
#
$url = 'https://example.com/my-páge'; $cleanUrl = t3lib_div::sanitizeLocalUrl($url); echo $cleanUrl;
https://example.com/my-pgeIn this example, the input URL contains non-ASCII characters, which are removed by the function to make the URL valid and safe. The t3lib_div library is included in the TYPO3 CMS package.