PHP | IntlChar::isupper()函数

这个 IntlChar::isupper() 函数是PHP中的一个内置函数,用于检查给定的输入字符是否为大写字符。

null

语法:

bool IntlChar::isupper( $codepoint )

参数: 此函数只接受一个参数 $codepoint 这是强制性的。输入参数是一个字符,它被编码为 UTF-8 一串

返回值: 如果 $codepoint 是大写字符,则返回True,否则返回False。

下面的程序说明了 IntlChar::isupper() PHP中的函数:

项目1:

PHP

<?php
// PHP code to illustrate IntlChar::isupper()
// function
// Input data is character type
var_dump(IntlChar::isupper( "G" ));
// Input data is control character
var_dump(IntlChar::isupper( " " ));
// Input data is string type
var_dump(IntlChar::isupper( "Geeksforgeeks" ));
// Input data is number type
var_dump(IntlChar::isupper( "2018" ));
// Input data is single digit
var_dump(IntlChar::isupper( "5" ));
?>


输出:

bool(true) bool(false) NULL NULL bool(false) 

注: 如果字符串和数字(除了一位数)用作参数,则返回NULL。

项目2:

PHP

<?php
// PHP code to illustrate IntlChar::isupper()
// Declare an array $arr
$arr = array ( "A" , "u{0041}" , "@" , "0" , "" , "123" , "Geeks" );
// u{0041} is ASCII value of 'A'
// Loop run for every array element
foreach ( $arr as $val ){
// Check each element as code point data
var_dump(IntlChar::isupper( $val ));
}
?>


输出:

bool(true) bool(true) bool(false) bool(false) bool(false) NULL NULL 

相关文章:

参考: http://php.net/manual/en/intlchar.isupper.php

© 版权声明
THE END
喜欢就支持一下吧
点赞8 分享