Re: variable type - conversion/checking

From: Date: Sat, 16 Mar 2013 00:31:00 +0000
Subject: Re: variable type - conversion/checking
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.general 
Request: Send a blank email to php-general+get-320591@lists.php.net to get a copy of this message
On 03/15/2013 02:33 PM, richard gray wrote:
On 15/03/2013 22:00, Ashley Sheridan wrote:
On Fri, 2013-03-15 at 04:57 -0500, tamouse mailing lists wrote: For my money, is_numeric() does just what I want. The thing is, is_numeric() will not check if a string is a valid int, but any valid number, including a float. For something like this, wouldn't a regex be better? if(preg_match('/^\-?\d+$/', $string)) echo int
I'm late in on this thread so apologies if I have missed something here .. but wouldn't is_int() do what the OP wants? rich
Nope, because the OP wants to test if a variable, that is a string, could be converted to an integer. Not if a variable is an integer. -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/

« previous php.general (#320591) next »