= 4.0.4, PHP 5, PHP 7, PHP 8)ctype_cntrl — 做控制字符檢測說明ctype_cntrl(string $text): bool檢查提供的 string 和 text 里面的字符是不是都是控制字符。 控制字符就是例如:換行、">

ctype_cntrl

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

ctype_cntrl做控制字符檢測

說明

ctype_cntrl(string $text): bool

檢查提供的 stringtext 里面的字符是不是都是控制字符。 控制字符就是例如:換行、縮進(jìn)、空格。

參數(shù)

text

需要被測試的字符串。

返回值

如果在當(dāng)前的語言環(huán)境下 text 里面的每個(gè)字符都是控制字符,就返回 true ;反之就返回 false 。

范例

示例 #1 一個(gè) ctype_cntrl() 例子

<?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";
    } else {
        echo 
"The string '$name' does not consist of all control characters.\n";
    }
}
?>

以上例程會輸出:

The string 'string1' consists of all control characters.
The string 'string2' does not consist of all control characters.

注釋

注意:

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

參見