Code:
<?php
header( "content-type:text/html;charset=utf-8 ");
$url = "http://blog.tianya.cn/blogger/rss.asp?BlogID=1160730 ";
$rss = simplexml_load_file($url);
? >
<html >
<head >
<title >Title </title >
</head >
<body >
<h1 >Content </h1 >
<?php
foreach ($rss- >channel- >item as $item) {
echo " <h2 > <a href= ' " . $item- >link . " ' > " . $item- >title . " </a > </h2 > ";
echo " <p > " . $item- >description . " </p > ";
}
? >
</body >
</html > Q:$url处为天涯博客rss时就会报错,错误信息“Warning: input conversion failed due to input error in rss.php on line 4
Warning: Bytes: 0xA3 0xA0 0xA3 0xA0 in rss.php on line 4
但$url为baidu空间rss,CSDN rss和一些其他rss时确可以正常显示。后来用javascript写时就都没问题。小的菜鸟一个,最近才接触simplexml,对一些操作一窍不通。请各位大侠指点一二,谢谢~~
<?php
header( "content-type:text/html;charset=utf-8 ");
$url = "http://blog.tianya.cn/blogger/rss.asp?BlogID=1160730 ";
$rss = simplexml_load_file($url);
? >
<html >
<head >
<title >Title </title >
</head >
<body >
<h1 >Content </h1 >
<?php
foreach ($rss- >channel- >item as $item) {
echo " <h2 > <a href= ' " . $item- >link . " ' > " . $item- >title . " </a > </h2 > ";
echo " <p > " . $item- >description . " </p > ";
}
? >
</body >
</html > Q:$url处为天涯博客rss时就会报错,错误信息“Warning: input conversion failed due to input error in rss.php on line 4
Warning: Bytes: 0xA3 0xA0 0xA3 0xA0 in rss.php on line 4
但$url为baidu空间rss,CSDN rss和一些其他rss时确可以正常显示。后来用javascript写时就都没问题。小的菜鸟一个,最近才接触simplexml,对一些操作一窍不通。请各位大侠指点一二,谢谢~~
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货