午夜国产狂喷潮在线观看|国产AⅤ精品一区二区久久|中文字幕AV中文字幕|国产看片高清在线

    php ctype函數(shù)中文翻譯和示例
    來源:易賢網(wǎng) 閱讀:848 次 日期:2014-08-22 09:38:50
    溫馨提示:易賢網(wǎng)小編為您整理了“php ctype函數(shù)中文翻譯和示例”,方便廣大網(wǎng)友查閱!

    這篇文章主要介紹了php ctype函數(shù)中文翻譯和示例,相關(guān)函數(shù)示例列出了多個,需要的朋友可以參考下

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

    代碼如下:

    $str = "0.1123";

    //檢查字符串所有字符是否為數(shù)字

    echo "ctype_digit:" . ctype_digit($str); //空

    //檢測是否為數(shù)字字符串,可為負(fù)數(shù)和小數(shù)

    echo "is_numberic:" . is_numeric($str); //1

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

    中文翻譯

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

    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)

    檢查是否是只包含類是“nrt”之類的字 符控制字符

    ctype_digit -- Check for numeric character(s)

    檢查時候是只包含數(shù)字字符的字符串(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

    檢查是否是只包含非數(shù)字/字符/空格的可打印出來的字符

    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進(jìn)制的字符串,只能包括 “0123456789abcdef”

    有示例的喲

    我們平常在遇到要對一些表單做簡單過濾的時候,往往不太愿意寫正則,而且在效率上,正則也是影響PHP運行速度的原因之一,所以在能不試用正則的時候盡量不試用正則。幸好PHP已經(jīng)為我們考慮到了這一點,給我提供了Ctype函數(shù)。下面對一些Ctype函數(shù)做一些簡單介紹,以備用:

    1、ctype_alnum — Check for alphanumeric character(s) 檢查字符串中只包含數(shù)字或字母,相當(dāng)于正則[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' => "nrt", '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ù)字

    代碼如下:

    <?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";

    }

    }

    ?>

    更多信息請查看IT技術(shù)專欄

    更多信息請查看網(wǎng)絡(luò)編程
    易賢網(wǎng)手機(jī)網(wǎng)站地址:php ctype函數(shù)中文翻譯和示例
    由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

    2025國考·省考課程試聽報名

    • 報班類型
    • 姓名
    • 手機(jī)號
    • 驗證碼
    關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機(jī)站點 | 投訴建議
    工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號
    云南網(wǎng)警備案專用圖標(biāo)
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
    云南網(wǎng)警報警專用圖標(biāo)