i am connecting to a third part tool using soap api. it accepts only utf8 encoding for the message.
sometimes I have special characters like “
and apostrophe
. which function best removes it or replaces with the equivalent in php
. I am using after setting
ini_set('default_charset', 'UTF-8');
function mail_utf8($message) {
return $message;
}
I am also running the string through urlencode
and urldecode
functions.
Use this
<?php
$headers = array();
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/plain; charset=iso-8859-1";
$headers[] = "From: Sender Name <sender@domain.com>";
$headers[] = "Bcc: JJ Chong <bcc@domain2.com>";
$headers[] = "Reply-To: Recipient Name <receiver@domain3.com>";
$headers[] = "Subject: {$subject}";
$headers[] = "X-Mailer: PHP/".phpversion();
mail($to, $subject, $email, implode("\r\n", $headers));
?>
您可以使用以下代码删除无效的UTF-8字符:
$text = iconv("UTF-8","UTF-8//IGNORE",$text);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.