本文整理汇总了PHP中BBCode::encode方法的典型用法代码示例。如果您正苦于以下问题:PHP BBCode::encode方法的具体用法?PHP BBCode::encode怎么用?PHP BBCode::encode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BBCode
的用法示例。
在下文中一共展示了BBCode::encode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: message_prepare
function message_prepare($message, $html_on, $bbcode_on)
{
#
# Clean up the message
#
$message = trim($message);
/*if ($html_on) {
$allowed_html_tags = split(',', 'b,i,u,pre');
$end_html = 0;
$start_html = 1;
$tmp_message = '';
$message = ' ' . $message . ' ';
while ($start_html = strpos($message, '<', $start_html)) {
$tmp_message .= BBCode::encode_html(substr($message, $end_html + 1, ($start_html - $end_html - 1)));
if ($end_html = strpos($message, '>', $start_html)) {
$length = $end_html - $start_html + 1;
$hold_string = substr($message, $start_html, $length);
if (($unclosed_open = strrpos(' ' . $hold_string, '<')) != 1) {
$tmp_message .= BBCode::encode_html(substr($hold_string, 0, $unclosed_open - 1));
$hold_string = substr($hold_string, $unclosed_open - 1);
}
$tagallowed = false;
for ($i = 0; $i < sizeof($allowed_html_tags); $i++) {
$match_tag = trim($allowed_html_tags[$i]);
if (preg_match('#^<\/?' . $match_tag . '[> ]#i', $hold_string)) {
$tagallowed = (preg_match('#^<\/?' . $match_tag . ' .*?(style[ ]*?=|on[\w]+[ ]*?=)#i', $hold_string)) ? false : true;
}
}
$tmp_message .= ($length && !$tagallowed) ? BBCode::encode_html($hold_string) : $hold_string;
$start_html += $length;
} else {
$tmp_message .= BBCode::encode_html(substr($message, $start_html));
$start_html = strlen($message);
$end_html = $start_html;
}
}
if ($end_html != strlen($message) && $tmp_message != '') {
$tmp_message .= BBCode::encode_html(substr($message, $end_html + 1));
}
$message = ($tmp_message != '') ? trim($tmp_message) : trim($message);
} else {*/
$message = BBCode::encode_html($message);
/*}*/
if ($bbcode_on) {
$message = BBCode::encode($message);
}
return $message;
}