当前位置: 首页>>代码示例>>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;未经允许,请勿转载。