ctype_graph
(PHP 4 >= 4.0.4, PHP 5, PHP 7)
ctype_graph - 检查空间以外的任何可打印字符
描述
bool ctype_graph ( string $text )检查提供的字符串text中的所有字符是否创建可见的输出。
参数
text
被测试的字符串。
返回值
如果文本中的每个字符都是可打印的并实际创建可见输出(无空格),则返回TRUE,否则返回FALSE。
例子
示例#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 "The string '$name' consists of all (visibly) printable characters.\n";
} else {
echo "The string '$name' does not consist of all (visibly) printable characters.\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.注意
注意:如果提供了-128到255之间的整数,则它将被解释为单个字符的ASCII值(为了允许扩展ASCII范围中的字符,负值将被添加256)。任何其他整数都被解释为包含整数的十进制数字的字符串。
扩展内容
- ctype_alnum() - 检查字母数字字符(s)
- ctype_print() - 检查可打印字符(s)
- ctype_punct() - 检查任何不是空格或字母数字字符的可打印字符
← ctype_digit
ctype_lower →
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com

