Filter Sanitize URL Constant in PHP



The FILTER_SANITIZE_URL constant removes all illegal URL characters from a string. It allows the following −

$-_.+!*'(),{}|\^~[]`"><#%;/?:@&=

Return

The FILTER_SANITIZE_URL constant does not return anything.

Example

 Live Demo

<?php
   $var = "www.example";
   var_dump(filter_var($var, FILTER_SANITIZE_URL));
?>

Output

The following is the output.

string(11) "www.example"
Updated on: 2020-06-27T08:52:04+05:30

410 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements