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

php ctype函數(shù)中文翻譯和示例

php Ctype擴(kuò)展是php4.2開(kāi)始就內(nèi)建的擴(kuò)展,注意,Ctype系列函數(shù)都只有一個(gè)字符串類(lèi)型參數(shù),它們返回布爾值。

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

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

中文翻譯

Ctype函數(shù)是php內(nèi)置的字符串體測(cè)函數(shù)。主要有以下幾種

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

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

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

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

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

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

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

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

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

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

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

有示例的喲

我們平常在遇到要對(duì)一些表單做簡(jiǎn)單過(guò)濾的時(shí)候,往往不太愿意寫(xiě)正則,而且在效率上,正則也是影響php運(yùn)行速度的原因之一,所以在能不試用正則的時(shí)候盡量不試用正則。幸好php已經(jīng)為我們考慮到了這一點(diǎn),給我提供了Ctype函數(shù)。下面對(duì)一些Ctype函數(shù)做一些簡(jiǎn)單介紹,以備用:
1、ctype_alnum ― Check for alphanumeric character(s)   檢查字符串中只包含數(shù)字或字母,相當(dāng)于正則[A-Za-z0-9].   有返回值。成功時(shí)返回TRUE,失敗為FALSE;
[復(fù)制代碼 代碼如下:
<?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)  檢查字符串中只包含字母。  成功時(shí)返回TRUE,失敗為FALSE;
復(fù)制代碼 代碼如下:
<?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' " 這樣的控制字符。
復(fù)制代碼 代碼如下:
<?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) 檢查字符串中是否只包含數(shù)字
復(fù)制代碼 代碼如下:
<?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技術(shù)php ctype函數(shù)中文翻譯和示例,轉(zhuǎn)載需保留來(lái)源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 日本人69xxx| 91极品蜜桃臀在线播放 | 999人在线精品播放视频 | 青青草AV国产精品 | 国产亚洲日韩另类在线观看 | 老人洗澡自拍xxx互摸 | 无码人妻视频又大又粗欧美 | 爆操大胸美女 | 国产最新精品亚洲2021不卡 | 边吃胸边膜下床震免费版视频 | 野花韩国高清完整版在线观看5 | 一本道高清不卡v免费费 | 97国产人妻精品无码AV在线 | 4399亚洲AV无码V无码网站 | 亚洲精品成人无码A片在线 亚洲精品成人久久久影院 亚洲精品成人a在线观看 | 麻豆AV蜜桃AV久久 | 日韩AV无码一区二区三区不卡毛片 | 国产成人精品视频播放 | 亚洲欧美人成视频在线 | 最近中文字幕2018MV高清在线 | 抽插的日日液液H | 亚洲精品第一页 | 香蕉99久久久久成人麻豆 | 久久天天婷婷五月俺也去 | 国产午夜亚洲精品区 | 羞羞麻豆国产精品1区2区3区 | 国色天香视频在线社区 | 精品国产免费人成视频 | 亚洲激情网站 | 拔擦拔擦8X永久华人免费播放器 | 九九热视频这里只有精 | 少妇厨房愉情理9伦片视频 少妇被躁爽到高潮无码久久 | 少妇伦子伦情品无吗 | 久久香蕉国产免费天天 | 欧美性猛交AAA片免费观看 | 久久久久综合 | 久久国产一区二区三区 | 国产亚洲精品久久久久久久软件 | 有人在线观看的视频吗免费 | 嫩草影院成人 | 欧美日韩看看2015永久免费 |