[PATCH] proposal for new function (str_type)

From: Date: Fri, 21 Nov 2003 20:42:19 +0000
Subject: [PATCH] proposal for new function (str_type)
Groups: php.internals 
Request: Send a blank email to internals+get-5649@lists.php.net to get a copy of this message
Hi everyone, I've attached a patch which adds a function that basically wraps the ctype.h functions. It pretty much just lets you check to see if a string contains only a certain set of characters. I think it would be very nice for input validation, particularly for those who fear regular expressions. Here's the prototype: bool str_type(str subject, int type) type is a bitmask created from a bunch of new constants (STR_TYPE_ALNUM, STR_TYPE_ALPHA, STR_TYPE_CNTRL, STR_TYPE_DIGIT, STR_TYPE_GRAPH, STR_TYPE_LOWER, STR_TYPE_PRINT, STR_TYPE_PUNCT, STR_TYPE_SPACE, STR_TYPE_UPPER, STR_TYPE_XDIGIT) If anyone is interested, there's a more exotic version at http://www.coeus-group.com/en/uploads/php_str_type.2.diff which allows as many parameters as you want, each of which can be either one of the above constants or a bitmask. It's not as clean as the attached version, and the attached version is definitely more similar to other functions, but I thought this way would be nice for people who are intimidated by bitmasks. If the attachment doesn't agree with anyone, it's also at http://www.coeus-group.com/en/uploads/php_str_type.1.diff -- Evan Nemerson evan@coeus-group.com -- "The greatest mistake is to imagine that the human being is an autonomous individual. The secret freedom which you can supposedly enjoy under a despotic government is nonsense, because your thoughts are never entirely your own. Philosophers, writers, artists, even scientists, not only need encouragement and an audience, they need constant stimulation from other people. It is almost impossible to think without talking. If Defoe had really lived on a desert island, he could not have written Robinson Crusoe, nor would he have wanted to. Take away freedom of speech, and the creative faculties dry up." -George Orwell

« previous php.internals (#5649) next »