【问题标题】:Problem with mutated vowel (umlauts) within a html/php contact-formhtml/php 联系人表单中的变异元音(元音变音)问题
【发布时间】:2019-07-26 13:19:40
【问题描述】:

即使设置了 UTF-8 声明,德语变异元音(ö、ä、ü 等)也无法在电子邮件中正确显示,通过 html/php 联系人表单发送。

PHP 文件:

    <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\n E-Mail: $email\n Message:\n $message";
    if ($_POST['submit']) {
    if ($name != '' && $email != '')

在 html 文件中也设置了 utf 声明:

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

特殊字符看起来像这样“ü”

【问题讨论】:

    标签: php html utf-8 contact-form


    【解决方案1】:

    对于php,您需要使用header 函数确保HTTP 标头设置为UTF-8

    试试this链接。

    简而言之:

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

    在发送任何数据之前调用它(就在您的 requireimport 语句之后)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-04
      相关资源
      最近更新 更多