FILTER_SANITIZE_URL

We can sanitize a URL by using FILTER_SANITIZE_URL.
$url = "https://www.plus 2 net.com "; 
echo $url;
$url_new= filter_var($url, FILTER_SANITIZE_URL);
echo "<br> After FILTER_SANITIZE_URL : $url_new ";
Output is here ( space is removed )
https://www.plus 2 net.com 
After FILTER_SANITIZE_URL : https://www.plus2net.com
This function removes all chars except letters, digits and $-_.+!*'(),{}|\\^~[]`<>#%";/?:@&=.

Example 2

$url = 'https://www.plus 2 net.com?id=123&mem=alex_#rt$k'; 
echo $url;
$url_new= filter_var($url, FILTER_SANITIZE_URL);
echo "<br> After FILTER_SANITIZE_URL : $url_new ";
OUtput is here
https://www.plus 2 net.com?id=123&mem=alex_#rt$k
After FILTER_SANITIZE_URL : https://www.plus2net.com?id=123&mem=alex_#rt$k


plus2net.com




Post your comments , suggestion , error , requirements etc here .




We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2020 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer