将波兰角色存储为PHP中的变量
我正在创建一个简单的注册表格,其中您必须将昵称输入到Textarea中。当用户使用波兰字符(Ś,,等)时,就会发生问题。当我尝试通过回声显示整个字符串时,它看起来应该如何,但是当我尝试仅显示一个字符时,它就会显示此怪异的符号。
function ech($nam)
{
echo $nam;
echo "</br>";
echo $nam[1];
}
$te = $_POST['sth']; //$te equals "śżć" now
ech($te);
输出:
ść
I am creating a simple registration form, in which you must type your nickname into textarea. The problem occurs when user uses polish characters (ś,ż,ć etc.). When I try to display the whole string by echo it looks just how it should, but when I try to display only one character then it shows this weird � symbol.
function ech($nam)
{
echo $nam;
echo "</br>";
echo $nam[1];
}
$te = $_POST['sth']; //$te equals "śżć" now
ech($te);
Output:
śżć
�
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用偏移量为字符串的字符,例如
$ nam [1]
实际上仅返回单个字节,但字符是多个字节。使用多级安全 - 安全字符串函数,例如mb_substr($ nam,0,1)
Using an offset for a character of a string like
$nam[1]
actually only returns a single byte, but the characters are multiple bytes. use multibyte-safe string functions likemb_substr($nam, 0, 1)