0
我開發了下面的代碼:服務器錯誤寫入或讀取文件時
if (time() - filemtime('current.txt') > 5)
{
$xml = simplexml_load_file("http://live.liveradio.ir:8000/liveradiomp3_48.xspf");
foreach($xml->children() as $child)
{
if ($child->getName() == 'trackList')
{
foreach($child as $child2)
{
if ($child2->getName() == 'track')
{
foreach($child2 as $child3)
{
if ($child3->getName() == 'title')
{
$fp = fopen('current.txt', 'w');
fwrite($fp, json_encode(array('data',$child3)));
fclose($fp);
}
}
}
}
}
}
}
echo (file_get_contents('current.txt'));
但是當我運行它,請參閱下頁:
Server error The website encountered an error while retrieving http://liveradio.ir/temp.php. It may be down for maintenance or configured incorrectly. Here are some suggestions: Reload this webpage later. HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.
的temp.php
和current.txt
權限是777。我評論下面的一行,問題解決了。
$fp = fopen('current.txt', 'w');
fwrite($fp, json_encode(array('data',$child3)));
fclose($fp);
echo (file_get_contents('current.txt'));
問題在哪裏?此代碼在本地主機上正常工作。
http://live.liveradio.ir:8000/liveradiomp3_48.xspf –
它不離線 –
我剛剛再次檢查。它處於離線狀態。 ;)也許它只是在愛爾蘭境內可用或類似的東西。你在錯誤信息中有這個:'http:// liveradio.ir/temp.php',但它不在你的代碼中,所以它似乎是一個維護頁面或類似的東西。想法:也許它只能通過特殊的「用戶代理」(如流媒體軟件)訪問,但不適用於瀏覽器,PHP腳本等? – Sliq