ctype_alpha是一個檢測函式,用來檢測所給參數是不是字母的函式。
基本介紹
- 中文名:檢查字母
- 外文名:ctype_alpha
- 函式原型:bool ctype_alpha
- 檢測:給定的參數是不是全部是字母
函式原型,函式範例,
函式原型
bool ctype_alpha ( string text )
檢查字母
ctype_alpha
(PHP 4 >= 4.0.4, PHP 5)
ctype_alpha -- 檢查字母
夏利提示:簡言之這個php內置的函式就是檢測給定的參數是不是全部是字母,注意:只需要傳進來一個參數,不區分大小寫,是字母都提示true
函式範例
<?php
$strings = array('KjgWZC', 'arf12');
foreach ($strings as $testcase) {
if (ctype_alpha($testcase)) {
echo "The string $testcase consists of all letters.\n";
} else {
echo "The string $testcase does not consist of all letters.\n";
}
}
?>
上例將輸出
The string KjgWZC consists of all letters. The string arf12 does not consists of all letters.