strtoupper() Function
函数的作用是:将字符串转换为大写。这个函数接受一个字符串作为参数,并将字符串中出现的所有小写英文字母转换为大写。字符串中的所有其他数字字符或特殊字符保持不变。
语法
1 | string strtoupper ( $string ) |
参数:此函数的唯一参数是要转换为大写的字符串。
返回值:这个函数返回一个字符串,其中所有字母都是大写的。
例子
1 2 3 4 5 6 7 | Input : $str = "sky8g" strtoupper($str) Output: SKY8G Input : $str = "going BACK he SAW THIS 123$#%" strtoupper($str) Output: GOING BACK HE SAW THIS 123$#% |
下面的程序演示了PHP中的strtoupper()函数:
程序1
1 2 3 4 5 6 7 8 9 10 11 | <?php // original string $str = "sky8g"; // string converted to upper case $resStr = strtoupper($str); print_r($resStr); ?> |
输出
1 | SKY8G |
程序2
1 2 3 4 5 6 7 8 9 10 11 | <?php // original string $str = "going BACK he SAW THIS 123$#%"; // string to upper case $resStr = strtoupper($str); print_r($resStr); ?> |
输出
1 | GOING BACK HE SAW THIS 123$#% |
参考