关于discuz的ubb转html的php方法

  • 作者:cyk
  • 未命名
  • 时间:2016-06-30 07:16:03
  • 9834人已阅读
 php  ubb 

其实在discuz内置了这个函数,只是如果对接再去调用似乎有些麻烦,于是我把他放在一个包中,调用即可

<?php
class ubb2html {
	function ubb($Text) {
		$Text = preg_replace(array('/&amp;(#\d{3,5};)/', "/\[hide=?\d*\](.*?)\[\/hide\]/is", "/\[\/?\w+=?.*?\]/"), array('&\\1', '<b>**** Hidden Message *****</b>', ''), str_replace(array('&', '"', '<', '>', "\t", '   ', '  '), array('&amp;', '&quot;', '&lt;', '&gt;', '&nbsp; &nbsp; &nbsp; &nbsp; ', '&nbsp; &nbsp;', '&nbsp;&nbsp;'), $Text));
		return $Text;
	}

}
?>

调用方法片段

$ubb = new ubb2html();
$uh = $ubb -> ubb($message);


发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

Top