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

81 阅读1分钟

ctype_space() - 语法

ctype_space ( $text );

此函数检查提供的字符串text中的所有字符是否创建空格。

Sr.No Parameter & Description
1

text(必需)

匹配字符串。

ctype_space() - 返回值

如果文本中的每个字符都创建了某种类型的空白,则返回TRUE,否则返回FALSE。除了空白字符外,这还包括制表符、垂直制表符、换行符、回车符和换页符。

ctype_space() - 示例

<?php
   $strings=array(

	, 	est123 );
   
   foreach ($strings as $test) {
      if (ctype_space($test)) {
         echo "$test consists of all whitespace characters.\n";
      }else {
         echo "$test does not have all whitespace characters.\n";
      }
   }
?> 

这将产生以下输出-

\n\r\t does not have all whitespace characters.
\test123 does not have all whitespace characters.

参考链接

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