= 4.0.4, PHP 5, PHP 7, PHP 8)ctype_graph — 做可打印字符串檢測,空格除外說明ctype_graph(string $text): bool檢查提供的 string 和 text 里面的字符輸出都是可見的。 參數(shù)text需">
(PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8)
ctype_graph — 做可打印字符串檢測,空格除外
$text
): bool
檢查提供的 string 和 text
里面的字符輸出都是可見的。
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ù)將會被解釋為該值對應的十進制字符串.