= 4.0.4, PHP 5, PHP 7, PHP 8)ctype_upper — 做大寫字母檢測說明ctype_upper(string $text): bool檢查 string 和 text 里面的字符是不是都是大寫字母。 參數(shù)text需要被測試的字符串">

ctype_upper

(PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8)

ctype_upper做大寫字母檢測

說明

ctype_upper(string $text): bool

檢查 stringtext 里面的字符是不是都是大寫字母。

參數(shù)

text

需要被測試的字符串。

返回值

在當(dāng)前語言環(huán)境下,如果 text 里面的每個字符都是大寫字母,就返回 true

范例

示例 #1 一個 ctype_upper() 例子 (使用當(dāng)前默認(rèn)語言環(huán)境)

<?php
$strings 
= array('AKLWC139''LMNSDO''akwSKWsm');
foreach (
$strings as $testcase) {
    if (
ctype_upper($testcase)) {
        echo 
"The string $testcase consists of all uppercase letters.\n";
    } else {
        echo 
"The string $testcase does not consist of all uppercase letters.\n";
    }
}
?>

以上例程會輸出:

The string AKLWC139 does not consist of all uppercase letters.
The string LMNSDO consists of all uppercase letters.
The string akwSKWsm does not consist of all uppercase letters.

注釋

注意:

如果給出一個 -128 到 255 之間(含)的int, 將會被解釋為該值對應(yīng)的ASCII字符 (負(fù)值將加上 256 以支持?jǐn)U展ASCII字符). 其它整數(shù)將會被解釋為該值對應(yīng)的十進制字符串.

參見