PHP头条
热点:

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



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

<?php
$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)

【本文版权归作者凡草0515与奥索网共同拥有,如需转载,请注明作者及出处】     

www.phpzy.comtrue/phprm/26882.htmlTechArticle从C/C++迁移到PHP——判断字符类型的函数 在C/C++中,头文件ctype.h中定义了关于字符类型一组宏,可以得到给定字符的类型。 而PHP中没有相关函数。前些天发现在www.mm4.de下载的PHP中提供...

相关文章

    暂无相关文章

PHP之友评论

今天推荐