Check if a String is ALL CAPS in PHP

前端 未结 9 2534
温柔的废话
温柔的废话 2020-12-05 22:46

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.

9条回答
  •  北荒
    北荒 (楼主)
    2020-12-05 23:13

    I think you are looking for this function

    $myString = "ABCDE";
    if (ctype_upper($myString)) // returns true if is fully uppercase
    {
        echo "the string $myString is fully uppercase";
    }
    

    Hope it helps

提交回复
热议问题