PHP FILTER_SANITIZE_URL Filter

Definition and Usage

The FILTER_SANITIZE_URL filter removes all illegal URL characters from the string.

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

  • Name: "url"
  • ID-number: 518

Example

<?php

var_dump(filter_var($var, FILTER_SANITIZE_URL));
?>

Output:

string(24) "http://www.codew3c.com"