|
 |
|
ใช้ฟังก์ชั่น BB Code แล้วเป็นภาษาต่างดาว?????????????????? |
|
 |
|
|
 |
 |
|
ตัวฐานข้อมูลก็ตั้งเป็น Utf8 ใน PageProperties ของ Dream ตั้งเป็น Thai(Window)
ตอนนำมาแสดงโดยไม่ผ่านฟังก์ชั่น BBCode ก็สามารถแสดงภาษาไทยได้ แต่เมื่อเรียกใช้ฟังก์ชั่นก็จะกลายเป็นภาษาต่างดาว
ไม่ทราบว่าจะเกี่ยวกับอะไร ช่วยหน่อยนะครับ หมดหนทางจริงๆๆ
Code (PHP)
function bbcode_format ($str) {
$str = htmlentities($str);
$simple_search = array(
//added line break
'/\[br\]/is',
'/\[b\](.*?)\[\/b\]/is',
'/\[i\](.*?)\[\/i\]/is',
'/\[u\](.*?)\[\/u\]/is',
'/\[url\=(.*?)\](.*?)\[\/url\]/is',
'/\[url\](.*?)\[\/url\]/is',
'/\[align\=(left|center|right)\](.*?)\[\/align\]/is',
'/\[img\](.*?)\[\/img\]/is',
'/\[mail\=(.*?)\](.*?)\[\/mail\]/is',
'/\[mail\](.*?)\[\/mail\]/is',
'/\[font\=(.*?)\](.*?)\[\/font\]/is',
'/\[size\=(.*?)\](.*?)\[\/size\]/is',
'/\[color\=(.*?)\](.*?)\[\/color\]/is',
//added textarea for code presentation
'/\[codearea\](.*?)\[\/codearea\]/is',
//added pre class for code presentation
'/\[code\](.*?)\[\/code\]/is',
//added paragraph
'/\[p\](.*?)\[\/p\]/is',
);
$simple_replace = array(
//added line break
'<br />',
'<strong>$1</strong>',
'<em>$1</em>',
'<u>$1</u>',
// added nofollow to prevent spam
'<a href="$1" rel="nofollow" title="$2 - $1" target="_blank">$2</a>',
'<a href="$1" rel="nofollow" title="$1" target="_blank">$1</a>',
'<div style="text-align: $1;">$2</div>',
//added alt attribute for validation
'<img src="$1" alt="" />',
'<a href="mailto:$1" target="_blank">$2</a>',
'<a href="mailto:$1" target="_blank">$1</a>',
'<span style="font-family: $1;">$2</span>',
'<span style="font-size: $1;">$2</span>',
'<span style="color: $1;">$2</span>',
//added textarea for code presentation
'<textarea class="code_container" rows="30" cols="70">$1</textarea>',
//added pre class for code presentation
'<pre class="code">$1</pre>',
//added paragraph
'<p>$1</p>',
);
// Do simple BBCode's
$str = preg_replace ($simple_search, $simple_replace, $str);
// Do <blockquote> BBCode
$str = bbcode_quote ($str);
return $str;
}
function bbcode_quote ($str) {
//added div and class for quotes
$open = '<blockquote><div class="quote">';
$close = '</div></blockquote>';
// How often is the open tag?
preg_match_all ('/\[quote\]/i', $str, $matches);
$opentags = count($matches['0']);
// How often is the close tag?
preg_match_all ('/\[\/quote\]/i', $str, $matches);
$closetags = count($matches['0']);
// Check how many tags have been unclosed
// And add the unclosing tag at the end of the message
$unclosed = $opentags - $closetags;
for ($i = 0; $i < $unclosed; $i++) {
$str .= '</div></blockquote>';
}
// Do replacement
$str = str_replace ('[' . 'quote]', $open, $str);
$str = str_replace ('[/' . 'quote]', $close, $str);
return $str;
}
Code (PHP)
while($row=mysql_fetch_array($sql)){
$showans=$row['an_detail'];
$showans=bbcode_format($showans);//เรียกฟังก์ชั่น
for($i=1;$i<=26;$i++){
$showans=ereg_replace("::E$i::"," <img src='images_board/Emo/E$i.gif'>",$showans);
}//for($i=1;$i<=26;$i++)
echo $shoeans;
Tag : PHP, HTML/CSS

|
ประวัติการแก้ไข 2010-09-10 11:35:33 2010-09-10 11:38:04
|
 |
 |
 |
 |
Date :
2010-09-10 10:58:59 |
By :
babyprogrammer |
View :
2284 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตอนที่ดึงมาก็ต้อง ใช้ Utf8 ด้วยนะครับ
|
 |
 |
 |
 |
Date :
2010-09-10 11:55:22 |
By :
SOUL |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตั้งทั้งหมดเป็น utf8 แล้วนะ ก็ไม่ได้มันน่าจะเป็นที่ฟังก์ชั่นรึป่าว
|
 |
 |
 |
 |
Date :
2010-09-10 13:23:12 |
By :
babyprogrammer |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ฺBroweser unicode utf8
|
 |
 |
 |
 |
Date :
2012-04-08 18:30:46 |
By :
Pp |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|