ctype函数

PHP ctype_cntrl()函数 (PHP ctype_cntrl() function)

ctype_cntrl() function is a character type (CType) function in PHP, it is used to check whether a given string contains all control characters or not.

ctype_cntrl()函数是PHP中的字符类型(CType)函数,用于检查给定的字符串是否包含所有控制字符。

It returns true if all characters of the given strings are control characters (like, a newline character, tab character, escape character etc). Else it returns false.

如果给定字符串的所有字符都是控制字符(例如,换行符,制表符,转义符等),则返回true 。 否则返回false 。

Note: Though control characters are unprintable character i.e. they cannot be represented in the string format if we represent they may display like symbols. So, we can provide the escape sequences in the string by following with forwarding slash (\), we can also provide the control character’s ASCII code in the range of hexadecimal values from 0x00 to 0x1f and 0x7f (Del).

注意:尽管控制字符是不可打印的字符,即如果我们表示它们可能显示为类似符号,则它们不能以字符串格式表示。 因此,我们可以在字符串后加上正斜杠( \ )来提供转义序列,还可以提供控制字符的ASCII代码,范围为从0x00到0x1f和0x7f (Del)的十六进制值。

To assign characters to value ASCII format (hexadecimal value), we use \x with the value.

要将字符分配给值ASCII格式(十六进制值),我们使用\ x作为值。

Syntax:

句法:

    ctype_cntrl(string) : bool

Example:

例:

    Input: "\r\n"
Output: true
Input: "\t\x12"
Output: true
Input: "\x00\x12\x1f\x7f"
Output: true
Input: "Hello123"
Output: false

PHP code:

PHP代码:

<?php
$str1 = "\r\n";
if(ctype_cntrl($str1))
echo ("str1 contains all control characters.\n");
else
echo ("str1 does not contain all control characters.\n");
$str2 = "\t\x12";
if(ctype_cntrl($str2))
echo ("str2 contains all control characters.\n");
else
echo ("str2 does not contain all control characters.\n");
$str3 = "\x00\x12\x1f\x7f";
if(ctype_cntrl($str3))
echo ("str3 contains all control characters.\n");
else
echo ("str3 does not contain all control characters.\n");
$str4 = "\r \n"; //space is there
if(ctype_cntrl($str4))
echo ("str4 contains all control characters.\n");
else
echo ("str4 does not contain all control characters.\n");
$str5 = "Hello123"; //alphabets & digits are there
if(ctype_cntrl($str5))
echo ("str5 contains all control characters.\n");
else
echo ("str5 does not contain all control characters.\n");
?>

Output

输出量

str1 contains all control characters.
str2 contains all control characters.
str3 contains all control characters.
str4 does not contain all control characters.
str5 does not contain all control characters.

翻译自: https://www.includehelp.com/php/ctype_cntrl-function-with-example.aspx

ctype函数

ctype函数_PHP ctype_cntrl()函数与示例相关推荐

  1. java回调函数_PHP回调函数及匿名函数概念与用法详解

    1.回调函数 PHP的回调函数其实和C.Java等语言的回调函数的作用是一模一样的,都是在主线程执行的过程中,突然跳去执行设置的回调函数: 回调函数执行完毕之后,再回到主线程处理接下来的流程 而在ph ...

  2. php rename函数_php rename函数怎么用

    PHP rename()函数用于重命名文件或目录,语法"rename(文件旧名称,新名称,句柄环境)",使用用户指定的新名称更改文件或目录的旧名称,并且可以根据需要在目录之间移动: ...

  3. php rename函数_PHP rename函数使用详解(php重命名文件)

    PHP中的rename()函数是一个内置函数,用于重命名文件或目录.它尝试用用户指定的新名称更改文件或目录的旧名称,并且在必要时可以在目录之间移动. 如果用户指定的新名称已经存在,rename()函数 ...

  4. mysql_assoc函数_PHP:MySQL函数mysql_fetch_assoc()的用法

    mysql_fetch_assoc (PHP 4 >= 4.0.3, PHP 5) mysql_fetch_assoc - 从结果集中取得一行作为关联数组 Warning 本扩展自 PHP 5. ...

  5. php 危险函数_PHP 危险函数有哪些?

    在编译 PHP 时,如无特殊需要,一定禁止编译生成 CLI 命令行模式的 PHP 解析支持.可在编译时使用 –disable-CLI.一旦编译生成 CLI 模式的PHP,则可能会被入侵者利用该程序建立 ...

  6. mysql addslashes()函数_PHP addslashes 函数

    一.函数功能: 数据库查询语句的要求,在单引号(').双引号(").反斜线(\)与 NUL(NULL 字符) 等特殊字符前添加反斜杠.它是stripslashes()函数的反向操作函数. 二 ...

  7. mysql rollback函数_PHP mysqli_rollback() 函数_程序员人生

    实例 关闭自动提交,做一些查询,提交查询,然后回滚当前事务: $con=mysqli_connect("localhost","my_user","m ...

  8. php mail函数_php 发送邮件函数

    /** * 记录数据 */ function runlog($mode = 'SMTP',$b = '',$c = '',$d='') { } /** * 发送邮件 * @param $toemail ...

  9. ctype函数_PHP ctype_xdigit()函数与示例

    ctype函数 PHP ctype_xdigit()函数 (PHP ctype_xdigit() function) ctype_xdigit() function is a character ty ...

最新文章

  1. php比较长的configure
  2. Linux二十年产权官司告终:IBM赔偿近亿元,期间“熬死”一位起诉方
  3. java命令行编译时提示找不到或无法加载主类的问题
  4. os和sys模块的常用方法
  5. 1130 Infix Expression (25 分)【难度: 一般 / 知识点: 中序遍历】
  6. centos内核参数优化
  7. android6.0源码分析之AMS服务源码分析
  8. StringBuilder与String互转
  9. 把骆驼命名法的变量,变为大写字母变小写且之前加下划线
  10. idea debug启动不了 模式下 报错 ‘Connected to the target VM,address:‘127.0.0.1:58337‘,transport:‘socket‘’
  11. java解码acc音频文件_(JAVA)将(acc/m4a)音频转换成Mp3格式
  12. linux初级:用useradd SB2,来建立新账户时,显示 bash:useradd:command not found的解决方法
  13. h264 pps sps详解
  14. 《云计算技术与应用基础》课程标准
  15. 俄语入门-俄语语音规则
  16. 李白藏头诗鸿蒙,【表白的诗句藏头诗】表白的诗句60句
  17. Python 编写函数实现交叉合并字符串,例如:ABCD与1234的合并结果是A1B2C3D4
  18. 做最好的创新(李开复)
  19. Python数据挖掘课程 五.线性回归知识及预测糖尿病实例
  20. 爱点击ICLK.US增持畅移,深度协同催生更多增长机会

热门文章

  1. php把中文写入mysql_php写入mysql中文乱码的实例解决方法
  2. Python二级笔记(1)
  3. 使用conda/pip安装pytorch 0.3.1教程(mac/windos/linux) pytorch 0.2.1
  4. Latex 表格 行合并,列合并,控制行间距 单元格宽度
  5. 采用递归求第n位数【C#】
  6. node+socket.io 实现一个聊天室
  7. 论文笔记:Person Re-identification with Deep Similarity-Guided Graph Neural Network
  8. 五阿哥钢铁电商平台Docker容器云平台建设实践——你想知道的都在这里!
  9. 在Microsoft System Center中利用您的现有投资管理VMware--Veeam MP v6.5
  10. 前方危险-让很多“高逼格”高管深刻反思的文章