ยินดีต้อนรับคุณ, บุคคลทั่วไป กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน

เข้าสู่ระบบด้วยชื่อผู้ใช้ รหัสผ่าน และระยะเวลาในเซสชั่น

ThaiSEOBoard.comพัฒนาเว็บไซต์Programming##ถามเซียนPHPเป็นภาษาต่างดาว แก้ยังไงครับ ดึงRSSมาแล้ว อ่านไม่ออก +1
หน้า: [1]   ลงล่าง
พิมพ์
ผู้เขียน หัวข้อ: ##ถามเซียนPHPเป็นภาษาต่างดาว แก้ยังไงครับ ดึงRSSมาแล้ว อ่านไม่ออก +1  (อ่าน 4642 ครั้ง)
0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้
danisthai
สมุนแก๊งเสียว
*

พลังน้ำใจ: 47
ออฟไลน์ ออฟไลน์

กระทู้: 730



ดูรายละเอียด เว็บไซต์
« เมื่อ: 13 สิงหาคม 2013, 19:50:08 »

เซียนๆphp ใครพอทราบบ้าง  แก้ยังไงครับ   wanwan017
สอบถามPHPเป็นภาษาต่างดาว  ดึงRSS.xmlมาแสดงผลในเว็บแล้ว  แต่อ่านไม่ออก  ดังรูปครับ



มีแค่2ไฟล์  ดังนี้ครับ
index.php
โค๊ด:
<div>
  <?php
  
include(&#39;rssclass.php&#39;);
  
$feedlist = new rss(&#39;http://www.mywebsite.com/rss/news.xml&#39;);
  
echo $feedlist->display(5,"ทันต่อเหตุการณ์");
 

  
?>

  </div>



rssclass.php
โค๊ด:
<?php
 
class rss {
     var 
$feed;

  function 
rss($feed
    {   
$this->feed $feed;  }
 
  function 
parse() 
    {
    
$rss simplexml_load_file($this->feed);
    
    
$rss_split = array();
    foreach (
$rss->channel->item as $item) {
    
$title = (string) $item->title// Title
    
$link   = (string) $item->link// Url Link
    
$description = (string) $item->description//Description
    
$rss_split[] = &#39;<div>
        
<a href="&#39;.$link.&#39;" target="_blank" title="" >
            &
#39;.$title.&#39; 
        
</a>
   <
hr>
          </
div>
&
#39;;
    
}
    return 
$rss_split;
  }
  function 
display($numrows,$head
  {
    
$rss_split $this->parse();

    
$i 0;
    
$rss_data = &#39;<div class="vas">
           
<div class="title-head">
         &
#39;.$head.&#39;
           
</div>
         <
div class="feeds-links">&#39;;
    
while ( $i $numrows 
   {
      
$rss_data .= $rss_split[$i];
      
$i++;
    }
    
$trim str_replace(&#39;&#39;, &#39;&#39;,$this->feed);
    
$user str_replace(&#39;&lang=en-us&format=rss_200&#39;,&#39;&#39;,$trim);
    
$rss_data.=&#39;</div></div>&#39;;
    
return $rss_data;
  }
}
?>



เซียนๆphp ใครพอรู้ไหมครับ   แก้ยังไง  +1 ขอบคุณครับ   wanwan017
« แก้ไขครั้งสุดท้าย: 13 สิงหาคม 2013, 19:51:23 โดย danisthai » บันทึกการเข้า

UnzO
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 54
ออฟไลน์ ออฟไลน์

กระทู้: 1,872



ดูรายละเอียด เว็บไซต์
« ตอบ #1 เมื่อ: 13 สิงหาคม 2013, 19:56:26 »

สั่ง Encoding หน้าที่ Display เป็น UTF-8 แล้วยังครับ

โค๊ด:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
บันทึกการเข้า
danisthai
สมุนแก๊งเสียว
*

พลังน้ำใจ: 47
ออฟไลน์ ออฟไลน์

กระทู้: 730



ดูรายละเอียด เว็บไซต์
« ตอบ #2 เมื่อ: 13 สิงหาคม 2013, 20:00:50 »

สั่ง Encoding หน้าที่ Display เป็น UTF-8 แล้วยังครับ

โค๊ด:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">


สั่งแล้วครับ  แบบนี้ใช่ไหมครับ
ผมใส่ไว้บนHead  แบบนี้ใช่ไหมครับ 
โค๊ด:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Title</title>
<link rel="stylesheet" href="tr.css" type="text/css">
</head>
แต่ไม่ได้ผล
ขอบคุณมากครับ
 wanwan017
บันทึกการเข้า

kppser
ก๊วนเสียว
*

พลังน้ำใจ: 36
ออฟไลน์ ออฟไลน์

กระทู้: 413



ดูรายละเอียด เว็บไซต์
« ตอบ #3 เมื่อ: 13 สิงหาคม 2013, 20:28:05 »

ลอง iconv('utf-8','tis-620',$data); ลองสลับดูคับ  wanwan002
บันทึกการเข้า

UnzO
หัวหน้าแก๊งเสียว
*

พลังน้ำใจ: 54
ออฟไลน์ ออฟไลน์

กระทู้: 1,872



ดูรายละเอียด เว็บไซต์
« ตอบ #4 เมื่อ: 13 สิงหาคม 2013, 23:08:24 »

เอา
โค๊ด:
<meta http-equiv="Content-Type" content="text/html; charset=tis-620" />
ออกครับ
บันทึกการเข้า
หน้า: [1]   ขึ้นบน
พิมพ์