文章詳情頁
從C/C++遷移到PHP——判斷字符類型的函數
瀏覽:4日期:2024-01-18 09:41:20
;;在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與奧索網共同擁有,如需轉載,請注明作者及出處】;;;;;
標簽:
PHP
上一條:PHP實現圖片簡單上傳下一條:PHP+APACHE實現用戶論證的方法
排行榜