本文整理汇总了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";
//-----------------------------------------------------------------------