
- PHP 7 Tutorial
- PHP 7 - Home
- PHP 7 - Introduction
- PHP 7 - Performance
- PHP 7 - Environment Setup
- PHP 7 - Scalar Type Declarations
- PHP 7 - Return Type Declarations
- PHP 7 - Null Coalescing Operator
- PHP 7 - Spaceship Operator
- PHP 7 - Constant Arrays
- PHP 7 - Anonymous Classes
- PHP 7 - Closure::call()
- PHP 7 - Filtered unserialize()
- PHP 7 - IntlChar
- PHP 7 - CSPRNG
- PHP 7 - Expectations
- PHP 7 - use Statement
- PHP 7 - Error Handling
- PHP 7 - Integer Division
- PHP 7 - Session Options
- PHP 7 - Deprecated Features
- PHP 7 - Removed Extensions & SAPIs
- PHP 7 Useful Resources
- PHP 7 - Quick Guide
- PHP 7 - Useful Resources
- PHP 7 - Discussion
FILTER_SANITIZE_ENCODED constant in PHP
The FILTER_SANITIZE_ENCODED constant encodes special characters.
Flags and Options
FILTER_FLAG_STRIP_LOW − Remove characters with ASCII value less than 32
FILTER_FLAG_STRIP_HIGH − Remove characters with ASCII value greater than 127
FILTER_FLAG_ENCODE_LOW − Encode characters with ASCII value less than 32
FILTER_FLAG_ENCODE_HIGH − Encode characters with ASCII value greater than 127
Return
The FILTER_SANITIZE_ENCODED constant does not return anything.
Example
The following is an example that use FILTER_FLAG_ENCODE_HIGH flag to encode characters with ASCII value > 127
Example
<?php $url="wwwÅ.exampleÅ.com"; $url = filter_var($url, FILTER_SANITIZE_ENCODED, FILTER_FLAG_STRIP_HIGH); echo $url; ?>
Output
The following is the output.
www.example.com
Let us see another example.
Example
<?php $url="example.com££"; $url = filter_var($url, FILTER_SANITIZE_ENCODED, FILTER_FLAG_STRIP_HIGH); echo $url; ?>
Output
Here is the output.
example.com
- Related Articles
- FILTER_VALIDATE_BOOLEAN constant in PHP
- FILTER_VALIDATE_EMAIL constant in PHP
- FILTER_VALIDATE_FLOAT constant in PHP
- FILTER_VALIDATE_INT constant in PHP
- FILTER_VALIDATE_IP constant in PHP
- FILTER_VALIDATE_REGEXP constant in PHP
- FILTER_VALIDATE_URL constant in PHP
- FILTER_SANITIZE_EMAIL constant in PHP
- FILTER_SANITIZE_MAGIC_QUOTES constant in PHP
- FILTER_SANITIZE_NUMBER_FLOAT constant in PHP
- FILTER_SANITIZE_NUMBER_INT constant in PHP
- FILTER_SANITIZE_SPECIAL_CHARS constant in PHP
- FILTER_SANITIZE_STRING constant in PHP
- FILTER_SANITIZE_STRIPPED constant in PHP
- FILTER_SANITIZE_URL constant in PHP

Advertisements