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

48 阅读1分钟

ctype_print() - 语法

ctype_print ( $text );

此函数检查提供的字符串text中的所有字符是否均可打印。

Sr.No Parameter & Description
1

text(必需)

匹配字符串。

ctype_print() - 返回值

如果文本中的每个字符都将实际创建输出(包括空格),则返回true。如果文本包含控制字符或根本不具有任何输出或控制功能的字符,则返回False。

ctype_print() - 示例

<?php
   $strings=array(asdf

	, k211, "fooo#int%@");
   
   foreach ($strings as $test) {
      if (ctype_print($test)) {
         echo "$test consists of all printable characters.\n";
      }else {
         echo "$test does not have all printable characters.\n";
      }
   }
?> 

这将产生以下输出-

asdf\n\r\t consists of all printable characters.
k211 consists of all printable characters.
fooo#int%@consists of all printable characters.

参考链接

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