我使用simpleXML构建了一个站点来从XML页面中提取内容。
我刚刚将网站切换到客户端服务器,从XML表中提取的页面不再起作用。
测试服务器是PHP版本5.2.9
客户端服务器是PHP 5.2.5版
allow_url_fopen
已启用两台服务器。
有什么想法吗?
class award{
var $xml;
var $awards;
function titles(){
$this->fullArticle();
$xml=simplexml_load_file("awards.xml");
foreach($xml->award as $currentAward){
$titles=$currentAward->title;
echo '<li><a href="';
base_url();
echo 'about/awards.php?award=';
echo $titles;
echo '">' . str_replace(array('<h1>','</h1>'), '', $currentAward->$titles->h1->asXML()) . '</a></li>';
}
}
function fullArticle(){
$awards=array();
$xml=simplexml_load_file("awards.xml");
foreach($xml->award as $currentAward){
array_push($awards, $currentAward->title);
}
return($awards);
}
function articleBlock($awardy){
$xml=simplexml_load_file("awards.xml");
foreach($xml->award as $currentAward){
if($currentAward->title = $awardy ){
echo str_replace(array('<'.$awardy.'>','</'.$awardy.'>'), '', $currentAward->$awardy->asXML());
}
}
}
}
答案 0 :(得分:1)
添加更多错误处理和调试代码
<?php
assert_options(ASSERT_ACTIVE, 1);
assert_options(ASSERT_BAIL, 1);
assert_options(ASSERT_QUIET_EVAL, 1);
error_reporting(E_ALL);
ini_set('display_errors', 1);
class award {
function titles() {
$xml=simplexml_load_file("awards.xml");
if (!$xml) {
throw new Exception("cannot read awards.xml");
}
assert( isset($xml->award) );
foreach($xml->award as $currentAward) {
assert( isset($currentAward->title) );
assert( isset($currentAward->$titles) );
assert( isset($currentAward->$titles->h1) );
$titles=(string)$currentAward->title;
echo '<li><a href="';
base_url();
echo 'about/awards.php?award=';
echo urlencode($titles);
echo '">' . str_replace(array('<h1>','</h1>'), '', $currentAward->$titles->h1->asXML()) . '</a></li>';
}
}
答案 1 :(得分:1)
请检查您的服务器上是否启用了您的IP地址权限。如果没有,则启用它。