本文整理匯總了PHP中BBCode::nl2br方法的典型用法代碼示例。如果您正苦於以下問題:PHP BBCode::nl2br方法的具體用法?PHP BBCode::nl2br怎麽用?PHP BBCode::nl2br使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類BBCode
的用法示例。
在下文中一共展示了BBCode::nl2br方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: BBCode
// Show it as "plain HTML", that is, with only <b>, <i>, <u>, and <a>.
print "<h3 style='color:#090;'>As \"plain HTML\" (<b>, <i>, <u>, and <a> tags only):</h3>\n";
$bbcode = new BBCode();
$bbcode->SetPlainMode(true);
$output = $bbcode->Parse($input);
$output = $bbcode->nl2br($output);
print "<div class='bbcode' style='margin:1em;'>{$output}</div>\n";
print "<hr />\n";
//-----------------------------------------------------------------------
// Now the same thing, with 520 characters or less.
print "<h3 style='color:#090;'>As length-limited \"plain HTML\" (<b>, <i>, <u>, and <a> tags only):</h3>\n";
$bbcode = new BBCode();
$bbcode->SetPlainMode(true);
$bbcode->SetLimit(520);
$output = $bbcode->Parse($input);
$output = $bbcode->nl2br($output);
print "<div class='bbcode' style='margin:1em;'>{$output}</div>\n";
print "<hr />\n";
//-----------------------------------------------------------------------
// Okay, this time, do it as pure plain text: No HTML at all. We
// use plain-HTML mode and a couple of preg_replace calls to clean
// up the result.
print "<h3 style='color:#090;'>As plain text:</h3>\n";
$bbcode = new BBCode();
$bbcode->SetPlainMode(true);
$output = $bbcode->Parse($input);
$output = preg_replace("/<\\/?[buia][^>]*>/", "", $output);
$output = wordwrap($bbcode->UnHTMLEncode(strip_tags($output)));
print "<div class='bbcode' style='margin:1em;font:10pt Courier,mono,monospace;white-space:pre;'>{$output}</div>\n";
print "<hr />\n";
//-----------------------------------------------------------------------