本文整理汇总了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;
}
示例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;
}
}
}
示例3: convert_html_to_text
function convert_html_to_text($html)
{
return html2text::convert($html);
}