PHP FILTER_SANITIZE_NUMBER_INT Filter

What is FILTER_SANITIZE_NUMBER_INT in PHP?

Explanation

PHP FILTER_SANITIZE_NUMBER_INT is used to remove unwanted special characters from an integer value. It allows only digits . + and - in the integer value.
Name: "number_int"
ID-number: 519

Example :


<?php
$num="3+5abc";
echo filter_var($num, FILTER_SANITIZE_NUMBER_INT);
?>

Result :

3+5

In the above example, the special characters abc is removed from the variable $num.

PHP Topics


Ask Questions

Ask Question