[thelist] PHP - strings and integers

**1st Vamp** wes at pmason.karoo.co.uk
Mon Apr 8 10:39:01 CDT 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: MD5

You could always perform a reversable substraction or some on it, like:
$num++;
$num--;
If the contents of the variable are numerical this will result in a numerical check after this point returning true, while if its a string it'll return false. I'm sure
there's an easier method, but this works for me usually.

- - Vamp

Monday, April 08, 2002, 3:48:53 PM, Lachlan Cannon wrote:

> I'm currently trying to test if a year passed as part of a query string is a
> numeral or not. I am using urls with slashes instead of a query string, and
> breaking it up in php, so it comes originally as a string. This presents a
> problem, because I can't test to see if the number passed for a year is a
> numeral or not, since it came as a string. I can't just convert it across to
> be a numeral - I want to give an error page on incorrect values entered. How
> can I test to see if it really is a number?

> Thanks

> Lach

> <tip author="Lachlan" type="PHP">
> A 'stable' version of PHP-GTK has been released and can be downloaded at
> http://gtk.php.net . PHP-GTK can be used to make cross platform GUI
> applications using PHP.
> </tip>

-----BEGIN PGP SIGNATURE-----
Version: 2.6

iQINAwUAPLG5TutR7En81eJTAQH9sQ+5AVbix16Ddo72hwv08ErVJ1FkwhMABKUf
GdqjJHbRGbyneKGc8dkO+qpasrpLF4nUa3F0pW5nTOA/JHa+8stVk+wGQLCsY0lI
zMGqzm13uNoY30vnKriY+mifGXeJQwYYSwSbiso1t6Lza6q01Kg3ZBN0+qlDLV8U
NFhd3KK5TK2xrMN6lsYbZYCPqKqsIFxC7p9ToWa6pQWM2xRRArmmbpyTFDsu4aEU
mQUde1sZAQXgtsNJnhpsDM8b4t9BMNfIU2zJvhjZpqjoLKBOnOROT9dysSHlhw8n
bwtsck0DjFkuV49zEPvzdvrC2pZ8bSIuzW91HIEz566ZxJwm6PgRjV7oOXpFou8L
BKQd6vaACsvQetA4v8LvnNDFRNz59M3Zixv2YJ2jq5iT81nuqkWUCA8OQ1Xwc0LZ
K696I7Eg+kODuq4QOF2033ADWj7X60pDyB4H8m1goD6My9HBnINkRJboWRfBoWqt
vAtJEJ9icb58zom5PynUOTdx1R3Y9/s26vrVjkc/7eEGgpEJevcUGPN+iZPYWEGa
dAz92OTYh3VpvxqpjbOVjo4fahgh0jPjry2pIqUbR+C9egCOQPvtZNguY3WeABYo
VNQ6lB+lrTLRtH3MWo9LaORbyld7Or+kf/IMp+EHSbHlM27W2ta2k084x7KbI1IZ
=Q/lJ
-----END PGP SIGNATURE-----




More information about the thelist mailing list