ctype_print()检查可打印字符。如果文本中的每个字符都将实际创建输出(包括空格),则返回TRUE。如果文本包含控制字符或根本没有任何输出或控制功能的字符,则返回FALSE。
ctype_print(sr)
str-测试的字符串
如果文本中的每个字符都将实际创建输出(包括空格),则ctype_print()函数将返回TRUE。如果文本包含控制字符或根本没有任何输出或控制功能的字符,则返回FALSE。
以下是一个例子-
<?php
$arr = array('asdf\n\r\t', 'yu67', "fooo#int%@");
foreach ($arr as $x) {
if (ctype_print($x)) {
echo "$x has all printable characters. \n";
} else {
echo "$x does not have all printable characters. \n";
}
}
?>输出结果
asdf\n\r\t has all printable characters. yu67 consists of all printable characters. fooo#int%@ consists of all printable characters.