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


PHP html2text::convert方法代碼示例

本文整理匯總了PHP中html2text::convert方法的典型用法代碼示例。如果您正苦於以下問題:PHP html2text::convert方法的具體用法?PHP html2text::convert怎麽用?PHP html2text::convert使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在html2text的用法示例。


在下文中一共展示了html2text::convert方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: sl_send_email

function sl_send_email($to, $subject, $html, $plain = null, $attachment = null)
{
    if (empty($to)) {
        return false;
    }
    $hash = md5(date('r', time()));
    $headers['From'] = 'The LoveMachine <love@sendlove.us>';
    $headers['To'] = $to;
    if (!empty($html)) {
        if (empty($plain)) {
            $h2t = new html2text($html, 75);
            $plain = $h2t->convert();
        }
        $headers["Content-Type"] = "multipart/alternative; boundary=\"PHP-alt-{$hash}\"";
        $body = "\n--PHP-alt-{$hash}\nContent-Type: text/plain; charset=\"utf-8\"\nContent-Transfer-Encoding: 7bit\n\n" . $plain . "\n\n--PHP-alt-{$hash}\nContent-Type: text/html; charset=\"utf-8\"\nContent-Transfer-Encoding: 7bit\n\n" . $html . "\n\n--PHP-alt-{$hash}--";
        if ($attachment != null && !empty($attachment['name']) && !empty($attachment['content'])) {
            $headers["Content-Type"] = "multipart/mixed; boundary=\"PHP-mixed-{$hash}\"";
            //encode it with MIME base64,
            //and split it into smaller chunks
            $attachmentContent = chunk_split(base64_encode($attachment['content']));
            $body = "\n--PHP-mixed-{$hash}\nContent-Type: multipart/alternative; boundary=\"PHP-alt-{$hash}\"\n\n" . $body . "\n--PHP-mixed-{$hash}  \nContent-Type: {$attachment['type']}; name=\"{$attachment['name']}\"  \nContent-Transfer-Encoding: base64  \nContent-Disposition: attachment  \n\n{$attachmentContent}\n--PHP-mixed-{$hash}-- \n";
        }
    } else {
        $body = $plain;
    }
    send_authmail(array('sender' => 'authuser', 'server' => 'gmail-ssl'), $to, $subject, $body, $headers);
    return true;
}
開發者ID:highfidelity,項目名稱:love,代碼行數:28,代碼來源:send_email.php

示例2: renderFormatedString

 public function renderFormatedString($str, $format, $return = false)
 {
     if ($format == 'plain_text') {
         if (class_exists('html2text')) {
             $str = html2text::convert($str);
         } else {
             $str = strip_tags($str);
         }
         if ($return === false) {
             if (!headers_sent()) {
                 header('Content-Type: text/plain');
             }
             echo $str;
         } else {
             return $str;
         }
     }
 }
開發者ID:atelierspierrot,項目名稱:devdebug,代碼行數:18,代碼來源:Debugger.php

示例3: convert_html_to_text

 function convert_html_to_text($html)
 {
     return html2text::convert($html);
 }
開發者ID:ket-ed,項目名稱:autoemail,代碼行數:4,代碼來源:checkemail.php


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