note 55562 added to ref.ctype

From: Date: Sun, 07 Aug 2005 15:47:06 +0000
Subject: note 55562 added to ref.ctype
Groups: php.notes 
Request: Send a blank email to php-notes+get-93199@lists.php.net to get a copy of this message
As noted above unfortunately many PHP developers are seemingly unaware of these functions and are still using less efficient equivalents. Use the ctype functions for input type vaildation. Example wrapper function: function detect_type($str, $type_req = ''){ $type = array(); (ctype_alnum($str) === TRUE) ? ($type = 'alnum') : FALSE; (ctype_digit($str) === TRUE) ? ($type = 'digit') : FALSE; (ctype_alpha($str) === TRUE) ? ($type = 'alpha') : FALSE; return ($type === $type_req) ? TRUE : FALSE; } // end fun $str = 'AlphaString'; $type_req = 'alpha'; // Returns TRUE if the string is of the required type echo detect_type($str, $type_req); ---- Manual Page -- http://www.php.net/manual/en/ref.ctype.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+55562 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55562&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55562&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55562&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55562&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55562&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55562&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+55562&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#93199) next »