Remove all illegal URL characters from a string in PHP
Description
The following code shows how to remove all illegal URL characters from a string.
Example
/* w ww .j a v a2 s . c o m*/
<?php
$var="http://www.java??2s.co?m";
var_dump(filter_var($var, FILTER_SANITIZE_URL));
// This filter allows all letters, digits and $-_.+!*'(),{}|\\^~[]`"><#%;/?:@&=
?>
The code above generates the following result.