= 4.0.4, PHP 5, PHP 7, PHP 8)ctype_graph — 做可打印字符串檢測,空格除外說明ctype_graph(string $text): bool檢查提供的 string 和 text 里面的字符輸出都是可見的。 參數(shù)text需">

ctype_graph

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

ctype_graph做可打印字符串檢測,空格除外

說明

ctype_graph(string $text): bool

檢查提供的 stringtext 里面的字符輸出都是可見的。

參數(shù)

text

需要被測試的字符串。

返回值

如果 text 里面的每個字符都是輸出可見的(沒有空白),就返回 true ;反之就返回 false 。

范例

示例 #1 一個 ctype_graph() 例子

<?php
$strings 
= array('string1' => "asdf\n\r\t"'string2' => 'arf12''string3' => 'LKA#@%.54');
foreach (
$strings as $name => $testcase) {
    if (
ctype_graph($testcase)) {
        echo 
"The string '$name' consists of all (visibly) printable characters.\n";
    } else {
        echo 
"The string '$name' does not consist of all (visibly) printable characters.\n";
    }
}
?>

以上例程會輸出:

The string 'string1' does not consist of all (visibly) printable characters.
The string 'string2' consists of all (visibly) printable characters.
The string 'string3' consists of all (visibly) printable characters.

注釋

注意:

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

參見