You are here: Re: [PHP] security/sql issues with php « PHP « IT news, forums, messages
Re: [PHP] security/sql issues with php

Posted by Robert Cummings on 09/22/05 02:43

On Wed, 2005-09-21 at 19:21, Chris Shiflett wrote:
> Mikey wrote:
> > I have found that adding 0 and then running is_int() usually works.
>
> You mean always works. :-) Casting something to an integer and then
> checking to see if it's an integer doesn't tell you anything useful:
>
> <?php
>
> $int = 'this is not an int';
> $int += 0;
>
> if (is_int($int))
> {
> echo '$int is an integer';
> }
>
> ?>
>
> You're always going to see "$int is an integer" on the screen, even when
> $int is clearly not. As I mentioned, ctype_digit() fits the bill nicely:

Not if it's a float.

<?php

$int = '2.333';
$int += 0;

if (is_int($int))
{
echo '$int is an integer';
}
else
{
echo '$int is probably a float :)';
}

?>

Cheers,
Rob.
--
..------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'

 

Navigation:

[Reply to this 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

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