0

我使用 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());
            } 

            }


    }
}
4

2 回答 2

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>';
        }
    }
于 2009-06-30T20:19:18.810 回答
1

请检查您的服务器是否启用了 IP 地址权限。如果没有,则启用它。

于 2010-08-02T12:31:53.687 回答