(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.