ctype_punct
(PHP 4 >= 4.0.4, PHP 5, PHP 7)
ctype_punct - 检查任何不是空格或字母数字字符的可打印字符
描述
bool ctype_punct ( string $text )
检查提供的字符串文本中的所有字符是否都是标点符号。
参数
text
被测试的字符串。
返回值
如果文本中的每个字符都是可打印的,但不是字母,数字或空白,则返回TRUE;否则返回FALSE。
例子
示例#1 一个ctype_punct()示例
<?php
$strings?=?array('ABasdk!@!$#',?'!@?#?$',?'*&$()');
foreach?($strings?as?$testcase)?{
????if?(ctype_punct($testcase))?{
????????echo?"The?string?$testcase?consists?of?all?punctuation.\n";
????}?else?{
????????echo?"The?string?$testcase?does?not?consist?of?all?punctuation.\n";
????}
}
?>
上面的例子将输出:
The string ABasdk!@!$# does not consist of all punctuation.
The string !@ # $ does not consist of all punctuation.
The string *&$() consists of all punctuation.
注意
注意:如果提供了-128到255之间的整数,则它将被解释为单个字符的ASCII值(为了允许扩展ASCII范围中的字符,负值将被添加256)。任何其他整数都被解释为包含整数的十进制数字的字符串。
扩展内容
- ctype_cntrl() - 检查控制字符(s)
- ctype_graph() - 检查除空格以外的任何可打印字符
← ctype_print
ctype_space →
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com