Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 字符集UTF-8不显示Umlauts_Php_Forms_Utf 8 - Fatal编程技术网

Php 字符集UTF-8不显示Umlauts

Php 字符集UTF-8不显示Umlauts,php,forms,utf-8,Php,Forms,Utf 8,作为一个网络开发者,德语很烂 我有一个朋友。在头部,首先是: <meta charset="utf-8"> 在php.ini中,我的默认字符集是: default_charset="utf-8" 问题在于HTML/PHP,因为当我直接在数据库中编写Umlauts(äöü)时,PHP会得到正确的字符串,而我会将其转储。 另一方面,当我填写textarea并发送表单时,POST参数的var_dump每次都有2个问号,而不是Umlauts ä -> ?? 如何修复它?我绝望了,

作为一个网络开发者,德语很烂

我有一个朋友。在头部,首先是:

<meta charset="utf-8">
在php.ini中,我的默认字符集是:

default_charset="utf-8"
问题在于HTML/PHP,因为当我直接在数据库中编写Umlauts(äöü)时,PHP会得到正确的字符串,而我会将其转储。 另一方面,当我填写textarea并发送表单时,POST参数的var_dump每次都有2个问号,而不是Umlauts

ä -> ??

如何修复它?

我绝望了,所以我添加了一些Javascript,在表单发送之前替换文本框值中的Umlauts

$('form').submit( function(ev) {
var textarea = $('form textarea');
var text = textarea.val();

   text = text.replace(/ä/g,"&auml;");
   text = text.replace(/ö/g, '&ouml;');
   text = text.replace(/ü/g, '&uuml;');
   text = text.replace(/Ä/g, '&Auml;');
   text = text.replace(/Ö/g, '&Ouml;');
   text = text.replace(/Ü/g, '&Uuml;');
   text = text.replace(/ß/g, '&szlig;');

   textarea.val(text);
});
在PHP中,我使用html_entity_decode将数据写入数据库

    $sql_arr = array(
       'descr'     =>  html_entity_decode($db->sql_escape($request->variable('description', ''))),
       // Some more Data
    );

您是否尝试过以HTML格式设置
接受charset=“UTF-8”
。。。没有任何变化。我确信问题不在HTML中,而在数据库连接中。您是如何连接到数据库的?在建立连接后,您是否发布了
设置名称UTF8
?哈哈!有一天你可以试试日语-P
    $sql_arr = array(
       'descr'     =>  html_entity_decode($db->sql_escape($request->variable('description', ''))),
       // Some more Data
    );