PHP language problem

六月ゝ 毕业季﹏ 提交于 2019-12-07 21:12:28

问题


I have a php page that sends mails to a specific email with the data included in the form on this page. The mail has to be sent in the native language of the website (Arabic) but when I click the submit button on the form, the mail is received half readable (Arabic language) and the other part is unreadable (Symbols). I want to know how to solve this problem and be able to send the mail to be all readable in the native language? (except for user-input symbols)


回答1:


Encode your message as UTF-8 (see utf8_encode()) and prepend the following header:

$header  = 'MIME-Version: 1.0' . "\r\n";
$header .= 'Content-type: text/plain; charset=UTF-8' . "\r\n";

// example
mail($to, $subject, $message, $header . $more_headers);

EDIT:

Use mb_convert_encoding() to convert your message to utf8, from whatever encoding it's currently on:

$str = mb_convert_encoding($str, 'UTF-8');


来源:https://stackoverflow.com/questions/3522416/php-language-problem

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!