TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   is_numeric($X) V.S. ctype_digit($X) V.S. is_integer($X) (http://www.talkphp.com/absolute-beginners/3327-is_numeric-x-v-s-ctype_digit-x-v-s-is_integer-x.html)

Yoosha 09-06-2008 08:30 AM

is_numeric($X) V.S. ctype_digit($X) V.S. is_integer($X)
 
Hi,
What is difference between is_numeric($X) V.S. ctype_digit($X) V.S. is_integer($X)?
Tnx ;).

Salathe 09-06-2008 09:16 AM

The relevant PHP Manual pages (is_numeric, ctype_digit, is_integer) should provide a clear answer, but in short:
  • is_numeric checks if the argument has a numerical value (e.g. 123, "0xFF" [hexadecimal], 0123 [octal], "+012.345e6", 3.14 are all allowed)
  • ctype_digit checks if all of the characters in a string are digits (e.g. 12345 is ok, 3.14 is not [the decimal point is not a digit!])
  • is_integer (and is_int) checks if the argument is an integer (i.e. 23 is ok, "23" is not)

Yoosha 09-06-2008 11:26 AM

Very thanks. Resolved ;).


All times are GMT. The time now is 12:37 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0