Home  >  Article  >  Backend Development  >  Migrating from C/C++ to PHP - function to determine character type_PHP tutorial

Migrating from C/C++ to PHP - function to determine character type_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 16:02:15920browse


In C/C++, the header file ctype.h defines a set of macros about character types, which can get the type of a given character.
There are no related functions in PHP. A few days ago, I found that the PHP downloaded from www.mm4.de provides an extension library named php_ctype.dll.
After loading, I found that some such functions are provided, and I have compiled them for your reference.
After loading the php_ctype.dll file correctly in PHP, use to see the following information:
ctype
ctype functions enabled (experimental)
Then You can use the functions it provides. The usage of all functions is basically the same as in C/C++. The difference is that in C/C++, the function parameters are
character type (char), while in PHP, the function parameters can be strings (string). For example:

$string="123ADAADAD";
if(isalnum($string))
{
echo "Only uppercase and lowercase letters and numbers!" ;
}

?>

Attachment: Functions supported by php_ctype.dll
bool isalnum(string)
bool isalpha(string)
bool iscntrl( string)
bool isdigit(string)
bool isgraph(string)
bool islower(string)
bool isprint(string)
bool ispunct(string)
bool isspace(string)
bool isupper(string)
bool isxdigit(string)

[The copyright of this article is jointly owned by the author Fancao0515 and Aosuo.com. If you need to reprint, please indicate the author and source]  

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/316621.htmlTechArticleIn C/C++, the header file ctype.h defines a set of macros about character types, which can be obtained Specifies the type of character. There are no related functions in PHP. A few days ago, I found that in the PHP downloaded from www.mm4.de...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn