ctype函数_PHP ctype_space()函数与示例

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) : bool

Example:

例:

    Input: "\r\n"
    Output: true
    Input: " "
    Output: true
    Input: "Hello world"
    Output: false

PHP code:

PHP代码:

<?php
    $str = " ";
    if(ctype_space($str))
        echo ("$str contains whitespaces.\n");
    else
        echo ("$str does not contain whitespaces.\n");

    $str = "\r\n";
    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函数

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值