尝试从以下 URL 读取 XML 提要:http: //www.mister-baseball.com/feed/
但是,输出以某种方式编码错误,我不知道如何解决这个问题。我的代码如下所示:
$url = "http://www.mister-baseball.com/feed/";
// Check the cache first
$error = false;
if (!file_exists($cacheFile) || filemtime($cacheFile) < (time() - 60 * 5)) {
if ($xmlString = @file_get_contents($url, FILE_TEXT)) {
// WHEN I PRINT THE $xmlString HERE, IT LOOKS BAD
file_put_contents($cacheFile, $xmlString, LOCK_EX);
} else {
// THIS PART IS NOT REACHED
$logDate = date('d-M-Y H:i:s');
error_log("[$logDate] Cannot open XML news feed at $url");
$error = true;
}
}