PHP FILTER_SANITIZE_URL Filter

What is FILTER_SANITIZE_URL in PHP?

Explanation

PHP FILTER_SANITIZE_URL is used to remove all unwanted special characters from the given URL. It allows letters, digits and the following special characters $-_.+!*'(),{}|\^~[]`"><#%;/?:@&=
Name: "url"
ID-number: 518

Example :

<?php
$var="http://www.hscrip�s@$.com+";
echo filter_var($var, FILTER_SANITIZE_URL); ?>

Result :

http://www.hscrips.com

In the above example, the unwanted special characters from the given url is removed and output is given in the above result.

PHP Topics


Ask Questions

Ask Question