(PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8)
ctype_graph — 檢查是否有任何可列印字元(除了空格)
text
要測試的字串。
注意事項:
如果提供 -128 到 255 之間(含)的 整數,它會被解釋為單個字元的 ASCII 值(負值會加上 256,以便允許擴展 ASCII 範圍內的字元)。任何其他整數都會被解釋為包含該整數十進制數字的字串。
範例 #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 "字串 '$name' 由所有(可見)可列印字元組成。\n";
} else {
echo "字串 '$name' 並非由所有(可見)可列印字元組成。\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.