濮阳杆衣贸易有限公司

主頁 > 知識庫 > 自定義ubb代碼,preg_replace()函數(shù)的一些代碼

自定義ubb代碼,preg_replace()函數(shù)的一些代碼

熱門標簽:廣西智能外呼系統(tǒng)多少錢 外呼系統(tǒng)api對接 平?jīng)龈叩碌貓D標注商戶要收費嗎 地圖標注與公司業(yè)務(wù)關(guān)系 荊州智能電銷機器人 福建微碼電話機器人 提高電話機器人接通率 銷售電銷機器人詐騙 大學校門地圖標注
function ubb($Text) { 
  $Text=htmlspecialchars($Text); 
  $Text=ereg_replace("\r\n","br>",$Text); 
  $Text=ereg_replace("\r","br>",$Text); 
  $Text=nl2br($Text); 
  $Text=preg_replace("/\\t/is","  ",$Text); 
  $Text=preg_replace("/\[h1\](.+?)\[\/h1\]/is","h1>\\1/h1>",$Text); 
  $Text=preg_replace("/\[h2\](.+?)\[\/h2\]/is","h2>\\1/h2>",$Text); 
  $Text=preg_replace("/\[h3\](.+?)\[\/h3\]/is","h3>\\1/h3>",$Text); 
  $Text=preg_replace("/\[h4\](.+?)\[\/h4\]/is","h4>\\1/h4>",$Text); 
  $Text=preg_replace("/\[h5\](.+?)\[\/h5\]/is","h5>\\1/h5>",$Text); 
  $Text=preg_replace("/\[h6\](.+?)\[\/h6\]/is","h6>\\1/h6>",$Text); 

  $Text=preg_replace("/\[url\](http:\/\/.+?)\[\/url\]/is","a href=\\1>\\1/a>",$Text); 
  $Text=preg_replace("/\[url\](.+?)\[\/url\]/is","a href=\"http://\\1\">http://\\1/a>",$Text); 
  $Text=preg_replace("/\[url=(http:\/\/.+?)\](.*)\[\/url\]/is","a href=\\1>\\2/a>",$Text); 
  $Text=preg_replace("/\[url=(.+?)\](.*)\[\/url\]/is","a href=http://\\1>\\2/a>",$Text); 

  $Text=preg_replace("/\[img\](.+?)\[\/img\]/is","img src=\\1>",$Text); 
  $Text=preg_replace("/\[color=(.+?)\](.+?)\[\/color\]/is","font color=\\1>\\2/font>",$Text); 
  $Text=preg_replace("/\[size=(.+?)\](.+?)\[\/size\]/is","font size=\\1>\\2/font>",$Text); 
  $Text=preg_replace("/\[sup\](.+?)\[\/sup\]/is","sup>\\1/sup>",$Text); 
  $Text=preg_replace("/\[sub\](.+?)\[\/sub\]/is","sub>\\1/sub>",$Text); 
  $Text=preg_replace("/\[pre\](.+?)\[\/pre\]/is","pre>\\1/pre>",$Text); 
  $Text=preg_replace("/\[email\](.+?)\[\/email\]/is","a href=\\1>\\1/a>",$Text); 
  $Text=preg_replace("/\[i\](.+?)\[\/i\]/is","i>\\1/i>",$Text); 
  $Text=preg_replace("/\[b\](.+?)\[\/b\]/is","b>\\1/b>",$Text); 
  $Text=preg_replace("/\[quote\](.+?)\[\/quote\]/is","blockquote>font size='2' face='Courier New'>quote:/font>hr>\\1hr>/blockquote>", $Text); 
  $Text=preg_replace("/\[code\](.+?)\[\/code\]/is","blockquote>font size='2' face='Courier New'>code:/font>hr color='lightblue'>i>\\1/i>hr color='lightblue'>/blockquote>", $Text); 
  $Text=preg_replace("/\[sig\](.+?)\[\/sig\]/is","div style='text-align: left; color: darkgreen; margin-left: 5%'>br>br>--------------------------br>\\1br>--------------------------/div>", $Text); 
return $Text; 

function str($msg){
  global $admin;
  if(!$admin[html]) $msg=htmlspecialchars($msg);
  if($admin[ubb]) $msg=ubb($msg);
  $msg=nl2br($msg); #處理message
  $msg= str_replace("\n","",$msg); #處理message
  $msg= str_replace("\r","",$msg); #處理message
  return $msg;
}
function error($msg){
global $admin;
?>

中的
$Text=preg_replace("/\[h2\](.+?)\[\/h2\]/is","h2>\\1/h2>",$Text); 

里面的 ("/\[h2](.+?)\[\/h2]/is","h2>\\1/h2>",$text)

/\[h2](.+?)\[\/h2]/is  轉(zhuǎn)化成 h2>\\1/h2>

/\[h2](.+?)\[\/h2]/is  里面的 這些"/\(.+?)\&;"之類的符號是怎么看的?是什么意思?
______________________________________________________________________________________________

\是轉(zhuǎn)意,\本身是特殊符號,如果要作為普通字符就要用\來轉(zhuǎn)意,就是說\\表示()也是特殊符號,所以要用\轉(zhuǎn)意
您可能感興趣的文章:
  • php正則之函數(shù) preg_replace()參數(shù)說明
  • eregi_replace()中特殊字符的處理方法
  • javascript replace()用法詳解附實例代碼
  • javascript replace()正則替換實現(xiàn)代碼
  • js replace() 文本替換你所不知的
  • js中字符替換函數(shù)String.replace()使用技巧
  • PHP preg_replace() 正則替換所有符合條件的字符串
  • 淺談jQuery中replace()方法
  • 淺談javascript中replace()方法
  • 淺談C++中replace()方法

標簽:海南 婁底 樂山 內(nèi)江 衡陽 黔東 邯鄲 德陽

巨人網(wǎng)絡(luò)通訊聲明:本文標題《自定義ubb代碼,preg_replace()函數(shù)的一些代碼》,本文關(guān)鍵詞  自定義,ubb,代碼,preg,replace,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《自定義ubb代碼,preg_replace()函數(shù)的一些代碼》相關(guān)的同類信息!
  • 本頁收集關(guān)于自定義ubb代碼,preg_replace()函數(shù)的一些代碼的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    达日县| 兴国县| 隆化县| 文化| 新野县| 嘉黎县| 环江| 虹口区| 开江县| 昌平区| 逊克县| 浑源县| 乌鲁木齐市| 葫芦岛市| 深泽县| 榆树市| 松阳县| 玉林市| 姜堰市| 越西县| 盐亭县| 杭锦旗| 太康县| 临江市| 文化| 高安市| 嘉兴市| 邛崃市| 长乐市| 托里县| 民权县| 左权县| 元朗区| 榕江县| 葵青区| 东兰县| 三穗县| 玉田县| 长春市| 京山县| 自贡市|