开发者

PHP language problem

开发者 https://www.devze.com 2023-01-12 11:02 出处:网络
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)开发者_如何学Python but wh

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)开发者_如何学Python 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)


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');
0

精彩评论

暂无评论...
验证码 换一张
取 消