36-filtros avanzados en php

Utilizamos la function filter_var() para comprobar si una variable es de tipo intero y si es inferior a 200







<?php
$int = 122;
$min = 1;
$max = 200;

if (filter_var($int, FILTER_VALIDATE_INT, array("options" =>
array("min_range"=>$min, "max_range"=>$max))) === false) {
  echo("Variable value is not within the legal range");
} else {
  echo("Variable value is within the legal range");
}
?> 



...

Publicar un comentario

0 Comentarios