这是我的代码,我试图将char编码设置为utf-8,但它不起作用。 在éáőí字符看起来像ĂŠ。 在HTML中,字符集是utf-8并且有效,我认为php是错误的。 谢谢你的帮助!
PHP
<?php
$headers = 'Content-type: text/html; charset=utf-8' . "\r\n";
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: YourWebsite.com';
$to = 'anything@website.com';
$subject = 'Email Inquiry';
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
?>
<?php
if ($_POST['submit']) {
if (mail ($to, $subject, $body, $from, $headers)) {
echo '<p>Thank you for your email!</p>';
} else {
echo '<p>Oops! An error occurred. Try sending your message again.</p>';
}
}
?>