PHP 中的 ctype_punct()函数

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

ctype_punct() - 语法

ctype_punct ( $text );

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

Sr.No Parameter & Description
1

text(必需)

匹配字符串。

链接:https://www.learnfk.comhttps://www.learnfk.com/php/php-function-ctype-punct.html

来源:LearnFk无涯教程网

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.

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

技术教程推荐

软件工程之美 -〔宝玉〕

罗剑锋的C++实战笔记 -〔罗剑锋〕

正则表达式入门课 -〔涂伟忠〕

人人都用得上的写作课 -〔涵柏〕

小马哥讲Spring AOP编程思想 -〔小马哥〕

郭东白的架构课 -〔郭东白〕

Serverless进阶实战课 -〔静远〕

AI大模型之美 -〔徐文浩〕

Midjourney入门实践课 -〔Jovi〕

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