PHP FILTER_SANITIZE_ENCODED Filter

What is FILTER_SANITIZE_ENCODED in PHP?

Explanation

PHP FILTER_SANITIZE_ENCODED is used to remove or encode special characters in URL. It works similar to urlencode() function.
Name: "encoded"
ID-number: 514

Options


FILTER_FLAG_STRIP_LOW Strip characters with ASCII value below 32
FILTER_FLAG_STRIP_HIGH Strip characters with ASCII value above 32
FILTER_FLAG_ENCODE_LOW Encode characters with ASCII value below 32
FILTER_FLAG_ENCODE_HIGH Encode characters with ASCII value above 32

Example :


<?php
$val="//www.hscripts.com";
echo filter_var($val,FILTER_SANITIZE_ENCODED);
?>

Result :

http%3A%2F%2Fwww.hscripts.com

In the above example, the unwanted special characters(://) in the url is encoded as in the output.

PHP Topics


Ask Questions

Ask Question