ctype函数
PHP ctype_space()函数 (PHP ctype_space() function)ctype_space() function is a character type (CType) function in PHP, it is used to check whether a given string contains whitespace or not.
ctype_space()函数是PHP中的字符类型(CType)函数,用于检查给定的字符串是否包含空格。
Note: Whitespace contains some of the other things like "tabs" (horizontal, vertical), "line feed", "carriage return", and "form feed".
注意:空格包含其他一些内容,例如“制表符”(水平,垂直),“换行符”,“回车”和“换页符”。
It returns true – if the string contains whitespaces, else it returns false.
它返回true –如果字符串包含空格,则返回false 。
Syntax:
句法:
ctype_space(string) : boolExample:
例:
Input: "rn" Output: true Input: " " Output: true Input: "Hello world" Output: falsePHP code:
PHP代码:
<?php $str = " "; if(ctype_space($str)) echo ("$str contains whitespaces.n"); else echo ("$str does not contain whitespaces.n"); $str = "rn"; if(ctype_space($str)) echo ("$str contains whitespaces.n"); else echo ("$str does not contain whitespaces.n"); $str = "Hello world123"; if(ctype_space($str)) echo ("$str contains whitespaces.n"); else echo ("$str does not contain whitespaces.n"); $str = "[email protected]&a"; if(ctype_space($str)) echo ("$str contains whitespaces.n"); else echo ("$str does not contain whitespaces.n");?>Output
输出量
contains whitespaces. contains whitespaces.Hello world123 does not contain whitespaces.[email protected]&a does not contain whitespaces.翻译自: https://www.includehelp.com/php/ctype_space-function-with-example.aspx
ctype函数