检查字符串在PHP中是否全部大写 [英] Check if a String is ALL CAPS in PHP

查看:376
本文介绍了检查字符串在PHP中是否全部大写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查看字符串是否包含所有大写字母的最佳方法是什么?如果字符串还包含符号或数字,我仍然希望函数返回true.

What's the best way to see if a string contains all capital letters? I still want the function to return true if the string also contains symbols or numbers.

推荐答案

检查是否strtoupper($str) == $str

要处理非ASCII用法,请执行以下操作:

To handle non-ascii use:

mb_strtoupper($str, 'utf-8') == $str

这篇关于检查字符串在PHP中是否全部大写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆