Reply to Re: Checking if var is integer string or int

Your name:

Reply:


Posted by Bocah Sableng on 04/27/07 12:11

On Apr 27, 7:00 pm, Bocah Sableng <cahsabl...@gmail.com> wrote:
> On Apr 24, 1:27 am, Jim <j...@yahoo.com> wrote:
>
> > Hi guys,
>
> > The variable '$pixels' in the code below may be an integer type or an
> > integer represented as a string type. I need to check if the value is
> > indeed one of these. Is the following code the simplest I can get?
>
> > if (!is_int($pixels) && !ctype_digit($pixels))
> > {
> > // some code
>
> > }
>
> How about is_numeric() ?
>
> $pixels_numeric = 25;
> $pixels = '25';
> var_dump($pixels);
> var_dump($pixels_numeric);
> var_dump(is_numeric($pixels));
> var_dump(is_numeric($pixels_numeric));
> var_dump(!ctype_digit($pixels));
> var_dump(!ctype_digit($pixels_numeric));
> var_dump(!is_int($pixels) && !ctype_digit($pixels));
> var_dump(!is_int($pixels_numeric) && !ctype_digit($pixels_numeric));
>
> HTH

Oops.. too quick to respond.
Sorry for that. :(

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация