PHP 中的 ctype_graph() 函数
phpprogrammingserver side programming更新于 2025/11/22 12:00:00
ctype_graph() 函数检查除空格之外的任何可打印字符。如果字符串文本中的每个字符都是十进制数字,则返回 TRUE,否则返回 FALSE。
语法
ctype_graph(str)
参数
str − 测试的字符串。
返回
如果文本中的每个字符都可打印且实际创建可见输出(无空格),则 ctype_graph() 函数返回 TRUE,否则返回 FALSE。
示例
下面是一个例子 −
<?php
$arr = array('khy
\r\t', 'arf12', 'LKA#@%.54');
foreach ($arr as $demo) {
if (ctype_graph($demo)) {
echo "$demo consists of all (visibly) printable characters
";
} else {
echo "$demo does not have all (visibly) printable characters.
";
}
}
?>
输出
khy
\r\t consists of all (visibly) printable characters. arf12 consists of all (visibly) printable characters LKA#@%.54 consists of all (visibly) printable characters

