PHP 中的 ctype_print() 函数
phpprogrammingserver side programming更新于 2025/11/22 12:21:00
ctype_print() 检查可打印字符。如果文本中的每个字符实际上都会创建输出(包括空格),则返回 TRUE。如果文本包含控制字符或根本没有任何输出或控制功能的字符,则返回 FALSE。
语法
ctype_print(sr)
参数
str − 测试的字符串
返回
如果文本中的每个字符实际上都会创建输出(包括空格),则 ctype_print() 函数返回 TRUE。如果文本包含控制字符或根本没有任何输出或控制功能的字符,则返回 FALSE。
示例
下面是一个例子 −
<?php
$arr = array('asdf
\r\t', 'yu67', "fooo#int%@");
foreach ($arr as $x) {
if (ctype_print($x)) {
echo "$x has all printable characters.
";
} else {
echo "$x does not have all printable characters.
";
}
}
?>
输出
asdf
\r\t has all printable characters. yu67 consists of all printable characters. fooo#int%@ consists of all printable characters.

