ctype函数_PHP ctype_xdigit()函数与示例
ctype函數
PHP ctype_xdigit()函數 (PHP ctype_xdigit() function)
ctype_xdigit() function is a character type (CType) function in PHP, it is used to check whether a given string contains hexadecimal digits or not.
ctype_xdigit()函數是PHP中的字符類型(CType)函數,用于檢查給定的字符串是否包含十六進制數字。
It returns true, if all characters of the given strings are hexadecimal digits – which are 0,1,2,3,4,5,6,7,8,9,0,A,B,C,D,E,F,a,b,c,d,e,f. Else it returns false.
如果給定字符串的所有字符均為十六進制數字(即0、1、2、3、4、5、6、7、8、9、0,A,B,C,D,E,F) ,則返回true ,a,b,c,d,e,f 。 否則返回false 。
Syntax:
句法:
ctype_xdigit(string) : boolExample:
例:
Input: "ABCD1209"Output: trueInput: "9009aaff"Output: trueInput: "1234"Output: trueInput: "123G4"Output: falsePHP code:
PHP代碼:
<?php$str = "ABCD1209";if(ctype_xdigit($str))echo ("$str contains all hexadecimal digits.\n");elseecho ("$str does not contain all hexadecimal digits.\n");$str = "9009aaff";if(ctype_xdigit($str))echo ("$str contains all hexadecimal digits.\n");elseecho ("$str does not contain all hexadecimal digits.\n");$str = "1234";if(ctype_xdigit($str))echo ("$str contains all hexadecimal digits.\n");elseecho ("$str does not contain all hexadecimal digits.\n");$str = "123G4"; //Here, "G" is not an hexadecimal digitif(ctype_xdigit($str))echo ("$str contains all hexadecimal digits.\n");elseecho ("$str does not contain all hexadecimal digits.\n"); ?>Output
輸出量
ABCD1209 contains all hexadecimal digits. 9009aaff contains all hexadecimal digits. 1234 contains all hexadecimal digits. 123G4 does not contain all hexadecimal digits.翻譯自: https://www.includehelp.com/php/ctype_xdigit-function-with-example.aspx
ctype函數
總結
以上是生活随笔為你收集整理的ctype函数_PHP ctype_xdigit()函数与示例的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: PHP array_pop()函数与示例
- 下一篇: c语言if else语句_查找C程序的输
