当前位置: 首页>>代码示例>>PHP>>正文


PHP BBCode::SetLimit方法代码示例

本文整理汇总了PHP中BBCode::SetLimit方法的典型用法代码示例。如果您正苦于以下问题:PHP BBCode::SetLimit方法的具体用法?PHP BBCode::SetLimit怎么用?PHP BBCode::SetLimit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BBCode的用法示例。


在下文中一共展示了BBCode::SetLimit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

//----------------------------------------------------------------------------------
// Normally, we'd load the postings from a database, but for this example,
// we'll just include them right here.
$postings = array(372 => array('id' => 372, 'title' => "I Saw a Cow Today", 'date' => "2007-06-05 18:37:43", 'author' => "Jenny", 'descr' => "I took the scenic route to work today, and wouldn't you know it?  There was an Amish farmer walking along the side of the road with a cow on a leash.  I don't really know where he was going, but I was really surprised to see them, since the Amish usually don't get this close to the suburbs.  It makes you wonder if times have gotten hard for them too.  Food for thought, I think."), 373 => array('id' => 373, 'title' => "I Work with Idiots", 'date' => "2007-06-08 18:03:17", 'author' => "Jenny", 'descr' => "I swear this was the day of idiots at work.  First thing, right off the bat, Larry comes in talking on a cell phone, and I kid you not, he walks right smack into the end of the open glass door.  We could hear the [i]*smack*[/i] all throughout the entire office, and he had a red welt on his face for the rest of the day.  Then my boss comes in ranting and raving at us about forgetting to e-mail the Pinsky people, only to have Sam point out that he'd said in the yesterday's meeting that he'd do it himself.  And then at lunch, Sam was laughing so hard at one of Bill's jokes that she peed her pants (sorry, Sam!) and had to run out and buy a new pair.  I don't even [i]wanna[/i] say all the stupid crap that happened in the afternoon.  Does everybody have a workplace full of numbskulls like I do, or is this just spring fever or something?  Maybe it's just because it's Friday..."), 374 => array('id' => 374, 'title' => "Sunday in the Park with Geoff", 'date' => "2007-06-10 21:08:06", 'author' => "Jenny", 'descr' => "Geoff and I went out to the park in the city today just for something to do.  We bought these really awful burgers from a street vendor and some bottles of Coke, and then sat on the park bench nibbling them (did I mention the burgers were awful?) while we watched kids skateboarding around the benches.  There was one kid who was really good.  I watched him do a good three flips in the air just past the statue of John Adams, off that railing there, but it didn't last.  An old lady who was trying to feed the pigeons got scared and left, and she came back about ten minutes later with a police officer.  I really don't understand why the city kicks the kids out of the park, since they're not hurting anything.  I wonder if I'll be as cranky as she was when I get old?"));
//----------------------------------------------------------------------------------
$postings = array_reverse($postings);
// Posts in reverse chronological order
$num_postings = count($postings);
if ($num_postings > 10) {
    $num_postings = 10;
}
// At most 10 postings to output
$bbcode = new BBCode();
$bbcode->SetPlainMode(true);
// Use plain mode...
$bbcode->SetLimit(200);
// ...and limit to 200 characters.
// Loop for each of the ten (or fewer) posts we're generating.
for ($i = 0; $i < $num_postings; $i++) {
    $posting = $postings[$i];
    // Generate the basic meta-information about this post.
    print "<item>\n";
    print "<title>" . htmlspecialchars($posting['title']) . "</title>\n";
    print "<author>" . htmlspecialchars($posting['author']) . "</author>\n";
    print "<link>http://jenny-musings.example.com/?post=" . $posting['id'] . "</link>\n";
    // Convert the date from "YYYY-MM-DD HH:MM:SS" format to a timestamp...
    $date = $posting['date'];
    $year = substr($date, 0, 4);
    $month = substr($date, 5, 2);
    $day = substr($date, 8, 2);
    $hour = substr($date, 11, 2);
开发者ID:edgaraxe,项目名称:AnimeNetwork,代码行数:31,代码来源:rss_example.php

示例2: BBCode

$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";
//-----------------------------------------------------------------------
//  Same thing, with 520 characters or less.
print "<h3 style='color:#090;'>As length-limited plain text:</h3>\n";
$bbcode = new BBCode();
$bbcode->SetPlainMode(true);
$bbcode->SetLimit(520);
$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";
?>

</body>
</html>
开发者ID:edgaraxe,项目名称:AnimeNetwork,代码行数:30,代码来源:limit_example.php


注:本文中的BBCode::SetLimit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。