FILTER_SANITIZE_NUMBER_INT constant in PHP

PHPProgrammingServer Side Programming

The FILTER_SANITIZE_NUMBER_INT constant deletes all illegal characters from a number.

Return

The FILTER_SANITIZE_NUMBER_INT constant does not return anything.

Example

 Live Demo

<?php
   $var = "4-5+9p";
   var_dump(filter_var($var, FILTER_SANITIZE_NUMBER_INT));
?>

Output

The following is the output.

string(5) "4-5+9"
raja
Published on 04-Dec-2018 08:24:23
Advertisements