PHP FILTER_SANITIZE_NUMBER_INTFilters


PHP Filter 参考手册Complete PHP Filter Reference Manual

Definition and Usage

The FILTER_SANITIZE_NUMBER_INT filter removes all illegal characters from a number.

This filter allows all digits as well as . + -

  • Name: "number_int"
  • ID-number: 519

Examples

<?php
$number="5-2+3pp";

var_dump(filter_var($number, FILTER_SANITIZE_NUMBER_INT));
?>

The output of the code is shown below:

string(5) "5-2+3"


PHP Filter 参考手册Complete PHP Filter Reference Manual Other Extensions