PHP 中的 ctype_punct()函数

首页 / PHP入门教程 / PHP 中的 ctype_punct()函数

ctype_punct() - 语法

ctype_punct ( $text );

此函数检查提供的字符串text中的所有字符是否都是标点符号。

Sr.No Parameter & Description
1

text(必需)

匹配字符串。

ctype_punct() - 返回值

如果文本中的每个字符都是可打印的,则返回TRUE,但既不是字母、数字也不是空白,否则返回FALSE。

无涯教程网

ctype_punct() - 示例

<?php
   $strings=array('k211!@!$#', 'foo!#$bar', '*$()');
   
   foreach ($strings as $test) {
      if (ctype_punct($test)) {
         echo "$test consists of all punctuation.\n";
      }else {
         echo "$test does not have all punctuation.\n";
      }
   }
?> 

这将产生以下输出-

k211!@!$# does not have all punctuation.
foo!#$bar does not have all punctuation.
*$()  consists of all punctuation.

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

即时消息技术剖析与实战 -〔袁武林〕

DevOps实战笔记 -〔石雪峰〕

Kafka核心源码解读 -〔胡夕〕

etcd实战课 -〔唐聪〕

流程型组织15讲 -〔蒋伟良〕

编程高手必学的内存知识 -〔海纳〕

深入浅出分布式技术原理 -〔陈现麟〕

技术领导力实战笔记 2022 -〔TGO 鲲鹏会〕

结构会议力 -〔李忠秋〕

好记忆不如烂笔头。留下您的足迹吧 :)