您好,登錄后才能下訂單哦!
今天就跟大家聊聊有關如何在php中實現一個Ubb代碼編輯器函數,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結了以下內容,希望大家根據這篇文章可以有所收獲。
代碼如下:
<?php
/*
php Ubb代碼編輯器
*/
function get_ubb($ubb){
$ubb=preg_replace("/([B])(.*)([/B])/","<B>\2</B>" ,$ubb);//替換B粗體字
$ubb=preg_replace("/([I])(.*)([/I])/","<I>\2</I>" ,$ubb);
$ubb=preg_replace("/([U])(.*)([/U])/","<U>\2</U>" ,$ubb);
$ubb=preg_replace("/([LEF])(.*)([/LEF])/","<div align=left>\2</div>" ,$ubb);
$ubb=preg_replace("/([MID ])(.*)([/MID ])/","<div align=center>\2</div>" ,$ubb);
$ubb=preg_replace("/([RIG])(.*)([/RIG])/","<div align=right>\2</div>" ,$ubb);
$ubb=preg_replace("/([LINK])(.*)([/LINK])/","<a href=\2>\2</a>",$ubb);
$ubb=preg_replace("/([Email])(.*)([/Email])/","<a href=mailto:\2>\2</a>",$ubb);
$ubb=preg_replace("/([IMAGE])(.*)([/IMAGE])/","<img src=\2>",$ubb);
$ubb=preg_replace("/([FLASH])(.*)([/FLASH])/","<OBJECT codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0 classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 width=400 height=400><PARAM NAME=movie VALUE="\2"><PARAM NAME=quality VALUE=high><embed src="\2" quality=high pluginspage='https://cache.yisu.com/upload/information/20201209/266/43629 >" ,$ubb);
$ubb=preg_replace("/([FONT=)(.{1,10})(])(.*)([/FONT])/","<div style=font:\2>\4</div>" ,$ubb);
$ubb=preg_replace("/([FONT-SIZE=)([0-9]*)(])(.*)([/FONT-SIZE])/","<div style=font-size:\2px>\4</div>" ,$ubb);
$ubb=preg_replace("/([FONT-COLOR=)(.{1,10})(])(.*)([/FONT-COLOR])/","<div style=color:\2>\4</div>" ,$ubb);
//$ubb=preg_replace("/([])(.*)([/])/","" ,$ubb);
return $ubb;
}
$str=get_ubb($_POST['cont']);
$str="<div style=font:宋體>[FONT=黑體]asdasd</div><div style=font:Georgia>asdasdas[/FONT]</div>";
echo get_ubb($str);
?>
看完上述內容,你們對如何在php中實現一個Ubb代碼編輯器函數有進一步的了解嗎?如果還想了解更多知識或者相關內容,請關注億速云行業資訊頻道,感謝大家的支持。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。