Home > php教程 > php手册 > body text

从C/C++迁移到PHP判断字符类型的函数

WBOY
Release: 2016-06-21 09:06:37
Original
1097 people have browsed it

c++|函数

在C/C++中,头文件ctype.h中定义了关于字符类型一组宏,可以得到给定字符的类型。
而PHP中没有相关函数。前些天发现在www.mm4.de下载的PHP中提供了一个名为php_ctype.dll的扩展库,
加载后发现提供一部分此类的函数,特整理出来供大家参考。
在PHP中正确加载php_ctype.dll文件后,用可以看到以下信息:
ctype
ctype functions enabled (experimental)
然后就可以使用它所提供的函数了。所有函数的用法同C/C++基本相同,区别在于在C/C++中函数的参数是
字符型(char),而在PHP中函数的参数可以是字符串(string)。例如:

$string="123ADAADAD";
if(isalnum($string))
{
echo "只有大小写字母和数字!";
}

?>

附: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)


 



Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!