本文整理匯總了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;
}