本文整理汇总了PHP中UTF8::ConvertToASCII方法的典型用法代码示例。如果您正苦于以下问题:PHP UTF8::ConvertToASCII方法的具体用法?PHP UTF8::ConvertToASCII怎么用?PHP UTF8::ConvertToASCII使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UTF8
的用法示例。
在下文中一共展示了UTF8::ConvertToASCII方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SendEmail
//.........这里部分代码省略.........
$mimeboundary2 = $mimeboundary;
} else {
$mimeboundary2 = "--------" . self::MIME_RandomString(25);
$mimecontent .= "--" . $mimeboundary . "\r\n";
$mimecontent .= "Content-Type: multipart/alternative; boundary=\"" . $mimeboundary2 . "\"\r\n";
$mimecontent .= "\r\n";
}
if ($textmessage != "") {
if ($mimeboundary2 != "") {
$mimecontent .= "--" . $mimeboundary2 . "\r\n";
$mimecontent .= "Content-Type: text/plain; charset=UTF-8\r\n";
$mimecontent .= "Content-Transfer-Encoding: quoted-printable\r\n";
$mimecontent .= "\r\n";
} else {
$destheaders .= "Content-Type: text/plain; charset=UTF-8\r\n";
$destheaders .= "Content-Transfer-Encoding: quoted-printable\r\n";
}
$message = self::ConvertEmailMessageToRFC1341($textmessage);
$mimecontent .= $message;
$mimecontent .= "\r\n";
}
if ($htmlmessage != "") {
if ($mimeboundary2 != "") {
$mimecontent .= "--" . $mimeboundary2 . "\r\n";
$mimecontent .= "Content-Type: text/html; charset=UTF-8\r\n";
$mimecontent .= "Content-Transfer-Encoding: quoted-printable\r\n";
$mimecontent .= "\r\n";
} else {
$destheaders .= "Content-Type: text/html; charset=UTF-8\r\n";
$destheaders .= "Content-Transfer-Encoding: quoted-printable\r\n";
}
$message = self::ConvertEmailMessageToRFC1341($htmlmessage);
$mimecontent .= $message;
$mimecontent .= "\r\n";
}
if ($mimeboundary2 != "" && $mimeboundary != $mimeboundary2) {
$mimecontent .= "--" . $mimeboundary2 . "--\r\n";
}
// Process the attachments.
$y = count($attachments);
for ($x = 0; $x < $y; $x++) {
$mimecontent .= "--" . $mimeboundary . "\r\n";
$type = str_replace("\r", "", $attachments[$x]["type"]);
$type = str_replace("\n", "", $type);
$type = UTF8::ConvertToASCII($type);
if (!isset($attachments[$x]["name"])) {
$name = "";
} else {
$name = str_replace("\r", "", $attachments[$x]["name"]);
$name = str_replace("\n", "", $name);
$name = self::FilenameSafe($name);
}
if (!isset($attachments[$x]["location"])) {
$location = "";
} else {
$location = str_replace("\r", "", $attachments[$x]["location"]);
$location = str_replace("\n", "", $location);
$location = UTF8::ConvertToASCII($location);
}
if (!isset($attachments[$x]["cid"])) {
$cid = "";
} else {
$cid = str_replace("\r", "", $attachments[$x]["cid"]);
$cid = str_replace("\n", "", $cid);
$cid = UTF8::ConvertToASCII($cid);
}
$mimecontent .= "Content-Type: " . $type . ($name != "" ? "; name=\"" . $name . "\"" : "") . "\r\n";
if ($cid != "") {
$mimecontent .= "Content-ID: <" . $cid . ">\r\n";
}
if ($location != "") {
$mimecontent .= "Content-Location: " . $location . "\r\n";
}
$mimecontent .= "Content-Transfer-Encoding: base64\r\n";
if ($name != "") {
$mimecontent .= "Content-Disposition: inline; filename=\"" . $name . "\"\r\n";
}
$mimecontent .= "\r\n";
$mimecontent .= chunk_split(base64_encode($attachments[$x]["data"]));
$mimecontent .= "\r\n";
}
if ($mimeboundary != "") {
$mimecontent .= "--" . $mimeboundary . "--\r\n";
}
$message = $mimecontent;
}
if (isset($options["returnresults"]) && $options["returnresults"]) {
return array("success" => true, "toaddr" => $toaddr, "fromaddr" => $fromaddr, "headers" => $destheaders, "subject" => $subject, "message" => $message);
} else {
if (isset($options["usemail"]) && $options["usemail"]) {
$result = mail($toaddr, $subject, self::ReplaceNewlines("\n", $message), $destheaders);
if (!$result) {
return array("success" => false, "error" => self::SMTP_Translate("PHP mail() call failed."), "errorcode" => "mail_call_failed");
}
return array("success" => true);
} else {
return self::SendSMTPEmail($toaddr, $fromaddr, $destheaders . "\r\n" . $message, $options);
}
}
}