當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UTF8::ConvertToASCII方法代碼示例

本文整理匯總了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);
         }
     }
 }
開發者ID:unicarehealth,項目名稱:sso-server,代碼行數:101,代碼來源:smtp.php


注:本文中的UTF8::ConvertToASCII方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。