无涯教程-PHP - ctype_graph()函数

57 阅读1分钟

ctype_graph() - 语法

ctype_graph ( $text );

此函数检查提供的字符串text中的所有字符是否创建可见输出。

Sr.No Parameter & Description
1

text(必需)

匹配字符串。

ctype_graph() - 返回值

如果文本中的每个字符都是可打印的,并且实际创建了可见输出(没有空格),则返回true,否则返回false。

ctype_graph() - 示例

<?php
   $strings=array(asdf

	, arf12, LKA#@%.54);
   
   foreach ($strings as $test) {
      if (ctype_graph($test)) {
         echo "$test consists of all (visibly) printable characters\n";
      }else {
         echo "$test does not have all (visibly) printable characters.\n";
      }
   }
?> 

这将产生以下输出-

asdf\n\r\t consists of all (visibly) printable characters.
arf12 consists of all (visibly) printable characters
LKA#@%.54 consists of all (visibly) printable characters

参考链接

www.learnfk.com/php/php-fun…