欢迎来到福编程网,本站提供各种互联网专业知识!

自定义ubb代码,preg_replace()函数的一些代码

发布时间:2007-03-20 作者: 来源:转载
functionubb($Text){$Text=htmlspecialchars($Text);$Text=ereg_replace("\r\n","",$Text);$Text=ereg_replace("\r","",$Text);$Text=nl2br($Text);$Text=preg_replace("/\\t/is","",$Text);$Text=preg_replace("/\[h1\](.+?)\[\/h
functionubb($Text){
$Text=htmlspecialchars($Text);
$Text=ereg_replace("rn","

",$Text);
$Text=ereg_replace("r","

",$Text);
$Text=nl2br($Text);
$Text=preg_replace("/t/is","",$Text);
$Text=preg_replace("/[h1](.+?)[/h1]/is","

1

",$Text);
$Text=preg_replace("/[h2](.+?)[/h2]/is","

1

",$Text);
$Text=preg_replace("/[h3](.+?)[/h3]/is","

1

",$Text);
$Text=preg_replace("/[h4](.+?)[/h4]/is","

1

",$Text);
$Text=preg_replace("/[h5](.+?)[/h5]/is","
1
",$Text);
$Text=preg_replace("/[h6](.+?)[/h6]/is","
1
",$Text);

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

$Text=preg_replace("/[img](.+?)[/img]/is","",$Text);
$Text=preg_replace("/[color=(.+?)](.+?)[/color]/is","2",$Text);
$Text=preg_replace("/[size=(.+?)](.+?)[/size]/is","2",$Text);
$Text=preg_replace("/[sup](.+?)[/sup]/is","1",$Text);
$Text=preg_replace("/[sub](.+?)[/sub]/is","1",$Text);
$Text=preg_replace("/[pre](.+?)[/pre]/is","

1
",$Text);
$Text=preg_replace("/[email](.+?)[/email]/is","1",$Text);
$Text=preg_replace("/[i](.+?)[/i]/is","1",$Text);
$Text=preg_replace("/[b](.+?)[/b]/is","1",$Text);
$Text=preg_replace("/[quote](.+?)[/quote]/is","
quote:
1
",$Text);
$Text=preg_replace("/[code](.+?)[/code]/is","
code:1
",$Text);
$Text=preg_replace("/[sig](.+?)[/sig]/is","

--------------------------

1

--------------------------

",$Text);
return$Text;
}
functionstr($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;
}
functionerror($msg){
global$admin;
?>

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

1

",$Text);

里面的("/[h2](.+?)[/h2]/is","

1

",$text)

/[h2](.+?)[/h2]/is转化成

1

/[h2](.+?)[/h2]/is里面的这些"/(.+?)"之类的符号是怎么看的?是什么意思?
______________________________________________________________________________________________

是转意,本身是特殊符号,如果要作为普通字符就要用来转意,就是说表示()也是特殊符号,所以要用转意

相关推荐