php實(shí)現(xiàn)轉(zhuǎn)換ubb代碼的方法
更新時(shí)間:2015年06月18日 16:42:23 作者:瘋狂的流浪
這篇文章主要介紹了php實(shí)現(xiàn)轉(zhuǎn)換ubb代碼的方法,涉及php正則替換的使用技巧,需要的朋友可以參考下
本文實(shí)例講述了php實(shí)現(xiàn)轉(zhuǎn)換ubb代碼的方法。分享給大家供大家參考。具體如下:
function ubb2html($content)
{
global $article;
//是否自動識別
if ($article['isparseurl'] == "1")
{
$content = parseurl($content);
}
//自動識別結(jié)束
$content = eregi_replace(quotemeta("[b]"),quotemeta("<b>"),$content);
$content = eregi_replace(quotemeta("[/b]"),quotemeta("</b>"),$content);
$content = eregi_replace(quotemeta("[i]"),quotemeta("<i>"),$content);
$content = eregi_replace(quotemeta("[/i]"),quotemeta("</i>"),$content);
$content = eregi_replace(quotemeta("[u]"),quotemeta("<u>"),$content);
$content = eregi_replace(quotemeta("[/u]"),quotemeta("</u>"),$content);
$content = eregi_replace(quotemeta("[center]"),quotemeta("<center>"),$content);
$content = eregi_replace(quotemeta("[/center]"),quotemeta("</center>"),$content);
$content = eregi_replace(quotemeta("[quote]"),quotemeta("<table width=\"96%\" border=\"0\" cellspacing=\"3\" cellpadding=\"0\" style=word-break:break-all align=\"center\"><tr><td><b>引用:</b></td></tr><tr><td><hr width=\"100%\" noshade></td></tr><tr><td class=\"content\"><font color=\"#0000FF\">"),$content);
$content = eregi_replace(quotemeta("[/quote]"),quotemeta("</font></td></tr><tr><td><hr width=\"100%\" noshade></td></tr></table>"),$content);
$content = eregi_replace(quotemeta("復(fù)制代碼 代碼如下:"),quotemeta("<table width=\"96%\" border=\"0\" cellspacing=\"3\" cellpadding=\"0\" style=word-break:break-all align=\"center\"><tr><td><b>代碼:</b></td></tr><tr><td><hr width=\"100%\" noshade></td></tr><tr><td class=\"code\"><font color=\"#0000FF\">"),$content);
$content = eregi_replace(quotemeta(""),quotemeta("</font></td></tr><tr><td><hr width=\"100%\" noshade></td></tr></table>"),$content);
$content = eregi_replace("\\[images\\]([^\\[]*)\\[/images\\]","<a href=\"\\1\" target=\"_blank\"><img src=\"\\1\" border=0 onload=\"javascript:if(this.width>screen.width-333)this.width=screen.width-333\" title=\"用新窗口瀏覽原始圖片\"></a>",$content);
$content = eregi_replace("\\[url\\]www.([^\\[]*)\\[/url\\]", "<a href=\"http://www.\\1\" target=_blank>www.\\1</a>",$content);
$content = eregi_replace("\\[url\\]([^\\[]*)\\[/url\\]","<a href=\"\\1\" target=_blank>\\1</a>",$content);
$content = eregi_replace("\\[url=([^\\[]*)\\]([^\\[]*)\\[/url\\]","<a href=\"\\1\" target=_blank>\\2</a>",$content);
$content = eregi_replace("\\[email\\]([^\\[]*)\\[/email\\]", "<a href=\"mailto:\\1\">\\1</a>",$content);
//$content = preg_replace( '/javascript/i', 'java script', $content);
return $content;
}
希望本文所述對大家的php程序設(shè)計(jì)有所幫助。
相關(guān)文章
php防注入,表單提交值轉(zhuǎn)義的實(shí)現(xiàn)詳解
本篇文章是對php防注入,表單提交值轉(zhuǎn)義的實(shí)現(xiàn)進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06
實(shí)例解析PHP定時(shí)器的具體實(shí)現(xiàn)
我們在開發(fā)中常會需要程序定時(shí)的執(zhí)行一些操作,這時(shí)寫一個(gè)簡潔高效的定時(shí)器就非常有必要,關(guān)于定時(shí)器本文將給大家詳細(xì)的介紹,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值2021-09-09
使用Huagepage和PGO來提升PHP7的執(zhí)行性能
這篇文章主要介紹了使用Huagepage和PGO來提升PHP7的執(zhí)行性能的相關(guān)方案,來自于注明的PHP開發(fā)組成員Laruence的相關(guān)研究,需要的朋友可以參考下2015-11-11

