天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

php ctype函數中文翻譯和示例

php Ctype擴展是php4.2開始就內建的擴展,注意,Ctype系列函數都只有一個字符串類型參數,它們返回布爾值。

復制代碼 代碼如下:
$str = "0.1123";
//檢查字符串所有字符是否為數字
echo "ctype_digit:" . ctype_digit($str);  //空
//檢測是否為數字字符串,可為負數和小數
echo "is_numberic:" . is_numeric($str); //1

從上面可以看出ctype_digit()和is_numberic()的區別。

中文翻譯

Ctype函數是php內置的字符串體測函數。主要有以下幾種

ctype_alnum -- Check for alphanumeric character(s)
檢測是否是只包含[A-Za-z0-9]

ctype_alpha -- Check for alphabetic character(s)
檢測是否是只包含[A-Za-z]

ctype_cntrl -- Check for control character(s)
檢查是否是只包含類是“/n/r/t”之類的字 符控制字符

ctype_digit -- Check for numeric character(s)
檢查時候是只包含數字字符的字符串(0-9)

ctype_graph -- Check for any printable character(s) except space
檢查是否是只包含有可以打印出來的字符(除了空格)的字符串

ctype_lower -- Check for lowercase character(s)
檢查是否所有的字符都是英文字母,并且都是小寫的

ctype_print -- Check for printable character(s)
檢查是否是只包含有可以打印出來的字符的字符串

ctype_punct -- Check for any printable character which is not whitespace or an alphanumeric character
檢查是否是只包含非數字/字符/空格的可打印出來的字符

ctype_space -- Check for whitespace character(s)
檢查是否是只包含類是“ ”之類的字符和空格

ctype_upper -- Check for uppercase character(s)
檢查是否所有的字符都是英文字母,并且都是大寫的

ctype_xdigit -- Check for character(s) representing a hexadecimal digit
檢查是否是16進制的字符串,只能包括 “0123456789abcdef”

有示例的喲

我們平常在遇到要對一些表單做簡單過濾的時候,往往不太愿意寫正則,而且在效率上,正則也是影響php運行速度的原因之一,所以在能不試用正則的時候盡量不試用正則。幸好php已經為我們考慮到了這一點,給我提供了Ctype函數。下面對一些Ctype函數做一些簡單介紹,以備用:
1、ctype_alnum ― Check for alphanumeric character(s)   檢查字符串中只包含數字或字母,相當于正則[A-Za-z0-9].   有返回值。成功時返回TRUE,失敗為FALSE;
[復制代碼 代碼如下:
<?php 
$strings = array('AbCd1zyZ9', 'foo!#$bar'); 
foreach ($strings as $testcase) { 
    if (ctype_alnum($testcase)) { 
        echo "The string $testcase consists of all letters or digits./n"; // 輸出The string AbCd1zyZ9 consists of all letters or digits. 
    } else { 
        echo "The string $testcase does not consist of all letters or digits./n"; // 輸出 The string foo!#$bar does not consist of all letters or digits. 
    } 

?> 

2、ctype_alpha ― Check for alphabetic character(s)  檢查字符串中只包含字母。  成功時返回TRUE,失敗為FALSE;
復制代碼 代碼如下:
<?php 
$strings = array('KjgWZC', 'arf12'); 
foreach ($strings as $testcase) { 
    if (ctype_alpha($testcase)) { 
        echo "The string $testcase consists of all letters./n"; // 輸出 The string KjgWZC consists of all letters. 
    } else { 
        echo "The string $testcase does not consist of all letters./n";<span style="white-space:pre">   </span>// 輸出 The string arf12 does not consist of all letters. 
    } 

?> 

3、ctype_cntrl ― Check for control character(s)    檢查字符串中是否只包含" '/n' '/r' '/t' " 這樣的控制字符。
復制代碼 代碼如下:
<?php 
$strings = array('string1' => "/n/r/t", 'string2' => 'arf12'); 
foreach ($strings as $name => $testcase) { 
    if (ctype_cntrl($testcase)) { 
        echo "The string '$name' consists of all control characters./n"; // 輸出 The string 'string1' consists of all control characters. 
    } else { 
        echo "The string '$name' does not consist of all control characters./n"; // The string 'string2' does not consist of all control characters. 
    } 

?>  

4、ctype_digit ― Check for numeric character(s) 檢查字符串中是否只包含數字
復制代碼 代碼如下:
<?php 
$strings = array('1820.20', '10002', 'wsl!12'); 
foreach ($strings as $testcase) { 
    if (ctype_digit($testcase)) { 
        echo "The string $testcase consists of all digits./n"; 
    } else { 
        echo "The string $testcase does not consist of all digits./n"; 
    } 

?>  

php技術php ctype函數中文翻譯和示例,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 一边啪啪的一边呻吟声口述 | 欧美18videosex初次 | 亚洲国产三级在线观看 | 校花被扒衣吸乳羞羞漫画 | 轻轻挺进女教师的身体 | 国产做国产爱免费视频 | 女人张开腿让男人桶爽免 | 无敌在线视频观看免费 | 久久中文字幕人妻熟AV女蜜柚M | 国产三级多多影院 | 精品亚洲一区二区在线播放 | 青青草国产偷拍在线av | 纲手裸乳被爆白浆 | 无限资源日本2019版免费 | 99re2.久久热最新地址 | 欧洲馒头大肥p | 強姧伦久久久久久久久 | 欧美高清另类video | 甜性涩爱在线播放 | 娇妻被朋友玩得呻吟在线电影 | 解开美女胸衣2破解版 | 九色PORNY真实丨国产大胸 | 亚洲精品一二三 | 久久这里只精品热在线18 | 亚洲视频在线免费观看 | 久久国产精品麻豆AV影视 | 99视频免费在线 | 亚洲国产在线播放在线 | 自拍偷拍12p | 熟女久久久久久久久久久 | 国产色综合色产在线视频 | 亚洲精品天堂在线观看 | 97国产蝌蚪视频在线观看 | 草莓视频在线播放视频 | 丝袜美腿美女被狂躁在线观看 | WW.国产人妻人伦精品 | GOGOGO高清免费播放 | 国产一区二区三区乱码在线观看 | 国产专区青青草原亚洲 | 国产欧美精品一区二区三区-老狼 | 久久人妻少妇嫩草AV蜜桃35I |