日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

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

發布時間:2025/3/11 php 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ctype函数_PHP ctype_cntrl()函数与示例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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: trueInput: "\t\x12"Output: trueInput: "\x00\x12\x1f\x7f"Output: trueInput: "Hello123"Output: false

PHP code:

PHP代碼:

<?php$str1 = "\r\n";if(ctype_cntrl($str1))echo ("str1 contains all control characters.\n");elseecho ("str1 does not contain all control characters.\n");$str2 = "\t\x12";if(ctype_cntrl($str2))echo ("str2 contains all control characters.\n");elseecho ("str2 does not contain all control characters.\n");$str3 = "\x00\x12\x1f\x7f";if(ctype_cntrl($str3))echo ("str3 contains all control characters.\n");elseecho ("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");elseecho ("str4 does not contain all control characters.\n");$str5 = "Hello123"; //alphabets & digits are thereif(ctype_cntrl($str5))echo ("str5 contains all control characters.\n");elseecho ("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()函数与示例的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。