note 108805 modified in function.is-int by danbrown

From: Date: Fri, 25 May 2012 15:20:38 +0000
Subject: note 108805 modified in function.is-int by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-188228@lists.php.net to get a copy of this message
Simple checking for integer:

<?php
if (strval(intval($var)) == strval($var)) {
 // $var is integer
}
?>

This return true if and only if $var is really integer. Without letters next to it, without "+" sign etc.
We can use it in mysql query for example. --was-- Simple checking for integer: if (strval(intval($var)) == strval($var)) { // $var is integer } This return true if and only if $var is really integer. Without letters next to it, without "+" sign etc. We can use it in mysql query for example. http://php.net/manual/en/function.is-int.php

« previous php.notes (#188228) next »