Re: Test whether string is valid integer

From: Rutger Claes (rgc_at_rgc.tld-of-belgium)
Date: 11/11/04


Date: Thu, 11 Nov 2004 19:20:19 +0100

Paul E Collins wrote:

> Given a string variable (form input), how can I determine whether it
> represents a valid integer?
>
> is_numeric is true for floats as well as integers, and is_int always
> fails on a string.
>
> P.

intval( $string ) == $string

works for me...

-- 
Rutger Claes                                                rgc@rgc.tld
Replace tld with top level domain of belgium to contact me    pgp:0x3B7D6BD6
>From listening comes wisdom and from speaking repentance.


Relevant Pages

  • Re: Difference Between .com & .local
    ... It's called the TLD, or Top Level Domain name. ... Microsoft MVP - Directory Services ... Instead of the website you're using, try using OEx (Outlook Express ...
    (microsoft.public.windows.server.networking)
  • Extracting data from dump file
    ... I tried using the python csv method, ... just sends the whole thing as a string and the SQL INSERT ... fails with a "not enough args" error. ... using; as a delimiter and going back to csv; this fails to match ...
    (comp.lang.python)
  • Re: String concatenation function, request for comments.
    ... Well, here you are starting at the right end, the interface to your ... so it never fails barring memory exhaustion. ... string, so you can confidently pass the non-null results onward. ... You are also confident that the returned item can be passed to ...
    (comp.lang.c)
  • Re: [PHP5 & DOM] element extracted from doc suddenly not found in insertBefore() -- NS problem
    ... die("No tags found"); ... Replace tld with top level domain of belgium to contact me pgp:0x3B7D6BD6 ...
    (comp.lang.php)
  • Re: Linked Table Properties - using ODBC trying to rmv DATABASE NAME e
    ... > However, when I move it to my staging machine, the database Onyx_Dev ... > is no longer there and it fails. ... the provider's help file (for SQL Server, probably look in the Books On ... You haven't put any password string in the Connect string you posted: ...
    (microsoft.public.access.tablesdbdesign)

Loading