html / php联系表单中变异元音(变音符号)的问题

德语变异元音(ö,ä,ü等)在电子邮件中无法正确显示,通过html发送 / php contact-form甚至设置了UTF-8声明。</ p>

PHP文件:</ p>

 &lt; meta http-equiv =  “Content-Type”content =“text / html”;  charset =“utf-8”/&gt; 
&lt;?php
$ name = $ _POST ['name'];
$ email = $ _POST ['email'];
$ message = $ _POST [' 消息'];
$ from ='来自:网站';

$ to ='xxx@gmx.de';

$ subject ='嗨那里';
$ human = $ _POST ['human'];

$ body =“From:$ name
电子邮件:$ email
消息:
$ 消息“;
if($ _POST ['submit']){
if($ name!=''&amp;&amp; $ email!='')
</ code> </ pre>
\ n

在html文件中也设置了utf声明:</ p>

 &lt;!DOCTYPE html&gt; 
&lt; meta charset =“utf-8”&gt; \ n </ code> </ pre>

特殊字符看起来像“ü”</ p>
</ div>

展开原文

原文

German mutated vowels (ö,ä,ü, etc) are not displayed correctly in the emails, sent over a html/php contact-form even the the UTF-8 declaration is set.

PHP file:

    <meta http-equiv="Content-Type" content="text/html"; charset="utf-8" />
<?php
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];
    $from = 'From: Website'; 
    $to = 'xxx@gmx.de'; 
    $subject = 'Hi there';
    $human = $_POST['human'];

    $body = "From: $name
 E-Mail: $email
 Message:
 $message";
    if ($_POST['submit']) {
    if ($name != '' && $email != '')

In the html file the utf declaration is set as well:

<!DOCTYPE html>
<meta charset="utf-8">

The special characters looks like this "ü"

1个回答



对于 php </ code>,您需要使用 header </ code>函数来确保 HTTP </ code>标头设置为 UTF-8 </ code>。</ p>

尝试这个链接。</ p>

简而言之:</ p>

< pre class =“lang-php prettyprint-override”> header('Content-Type:text / html; charset = utf-8');
</ code> </ pre>

在发送任何数据之前调用此方法(在 require </ code>和 import </ code>语句之后)。</ p>
</ div>

展开原文

原文

For php you need to use the header function to make sure that the HTTP header is set to UTF-8.

Try this link.

In a nutshell:

header('Content-Type: text/html; charset=utf-8');

Call this before any data is sent (right after your require and import statements).

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问