gpt4 book ai didi

php - 简单的 strtolower 不起作用

转载 作者:可可西里 更新时间:2023-11-01 12:33:38 25 4
gpt4 key购买 nike

我确定这是我遗漏的明显东西,但我有一个存储为 $str 的字符串“GB”,然后使用 strtolower 回显...

$str = bp_member_profile_data('field=Country');
echo strtolower($str);

我期待看到“gb”(小写),但输出仍然是“GB”(大写)

我做错了什么?

更新事实证明,问题出在 bp_member_profile_data,这是一个自动回显的 BuddyPress PHP 函数,因此它忽略了 strtolower - 感谢大家帮助缩小范围!

最佳答案

尝试使用:

mb_strtolower($str);

这可能有效。

来自 PHP Manual :

If the input string is in different language that server locale, then you should use mb_strtolower() function.

函数原型(prototype)为:

string mb_strtolower ( string $str [, string $encoding = mb_internal_encoding() ] )

您可以尝试添加适当的编码。

The encoding parameter is the character encoding. If it is omitted, the internal character encoding value will be used.

关于php - 简单的 strtolower 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15724528/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com