Foros del Web » Programando para Internet » PHP »

Discriminar Integer y String

Estas en el tema de Discriminar Integer y String en el foro de PHP en Foros del Web. Tengo este formulario: Código PHP: < form action = "articulos.buscar.php"  method = "post" > Buscar : < input name = "criterio"  type = "text"  value = "" > ...
  #1 (permalink)  
Antiguo 26/01/2011, 10:08
Avatar de bandolera  
Fecha de Ingreso: abril-2009
Mensajes: 613
Antigüedad: 15 años
Puntos: 7
Pregunta Discriminar Integer y String

Tengo este formulario:
Código PHP:
<form action="articulos.buscar.php" method="post">
Buscar: <input name="criterio" type="text" value="">
<
input type="submit" value="Buscar"/>
</
form
Y en articulos.buscar.php tengo:
Código PHP:
$prod $_POST['criterio'];

if (
is_integer($prod))
{
ECHO 
"I";
}

if (
is_string($prod))
{
ECHO 
"S";

Solamente funciona la parte string, si en el formulario pongo un número igual hace la parte del string, por qué no ejecuta la parte integer si ingreso un número?
  #2 (permalink)  
Antiguo 26/01/2011, 10:14
Colaborador
 
Fecha de Ingreso: octubre-2009
Ubicación: Tokyo - Japan !
Mensajes: 3.867
Antigüedad: 14 años, 6 meses
Puntos: 334
Respuesta: Discriminar Integer y String

revisa la informacion de ctype_digit
www.php.net/ctype_digit

saludos =) !
  #3 (permalink)  
Antiguo 26/01/2011, 17:53
Avatar de Triby
Mod on free time
 
Fecha de Ingreso: agosto-2008
Ubicación: $MX->Gto['León'];
Mensajes: 10.106
Antigüedad: 15 años, 8 meses
Puntos: 2237
Respuesta: Discriminar Integer y String

Toda la informacion recibida por $_GET y $_POST es automaticamente string y por eso debes utilizar la funcion sugerida por Hidek1.
__________________
- León, Guanajuato
- GV-Foto

Etiquetas: integer, string
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:37.