[dev] ctype functions
Eric Rostetter
eric.rostetter at physics.utexas.edu
Sun Mar 9 00:19:53 PST 2003
Quoting Marko Djukic <marko at oblo.com>:
> according to the "editor's note" on
> http://www.php.net/manual/en/ref.ctype.php
> ctypes should be prefered to regex, and some is_* functions.
Yes, but only in HEAD as ctypes are not available in most php versions
until at least 4.2.
> so, anyone know if therefore ctype_digit() should be used instead of
> is_int()?
No idea.
> hwo about instead of preg_match('/^[0-9]+$/', $somevar) ?
It should be faster, though I've not tested. I also think it is more
clear and easier to read and code. So I would tend to use it here
just for clarity.
For other characters, ctype_* functions tend to be multibyte safe, so is
also nice compared to more traditional routines that are not multibyte
safe. Another win.
But, as I said, for BC we need to be careful about these, and only use
them in HEAD or in modules that require a new PHP version.
> marko
--
Eric Rostetter
The Department of Physics
The University of Texas at Austin
Why get even? Get odd!
More information about the dev
mailing list