PHP FILTER_SANITIZE_ENCODED Filter

Definition and Usage

The FILTER_SANITIZE_ENCODED filter removes or URL-encodes characters that are not needed for URL encoding.

This function is very similar to the urlencode() function.

  • Name: "encoded"
  • ID-number: 514

Possible options or flags:

  • FILTER_FLAG_STRIP_LOW - Remove characters with ASCII values below 32
  • FILTER_FLAG_STRIP_HIGH - Remove characters with ASCII values above 32
  • FILTER_FLAG_ENCODE_LOW - Encode characters with ASCII values below 32
  • FILTER_FLAG_ENCODE_HIGH - Encode characters with ASCII values above 32

Example

<?php

var_dump(filter_var($url,FILTER_SANITIZE_ENCODED));
?>

Output:

string(32) "http%3A%2F%2Fwww.codew3c.com"