【问题标题】:Porting PHP5 to legacy PHP4, DOMDocument quibbles将 PHP5 移植到旧版 PHP4,DOMDocument 小问题
【发布时间】:2011-03-31 00:25:15
【问题描述】:

我正在尝试让我的一些 php5 代码在旧版服务器上运行,但遗憾的是无法升级(客户端的机器)。

if (!isset($docRoot)) {
    $docRoot = $_SERVER['DOCUMENT_ROOT'];
}

// generic storage class for the words/phrases
$t = new stdClass();
$t->lang = $curPage->lang;



// load xml translations, could split this into different files..
$translations = new DOMDocument();
$translations->load($docRoot."/xml/translations.xml");

$words = $translations->getElementsByTagName("word");
$count = 0;
foreach( $words as $word )
{

    $name = $word->getAttribute('name');
    $trans = $word->childNodes;

    if ($trans->length > 0) {
        for($i = 0; $i < $trans->length; $i++) {
            $child = $trans->item($i); 



            if ($child->nodeName == $curPage->lang) {
                $t->$name = $child->nodeValue;
            }


        }
    }

}

据我所知,domdocument 在 php4 中缺少大量方法(它是 php4.4.4,在一个 centos 盒子上),其中一些似乎被全局静态函数取代..@987654322 @? XML 也有 UTF8 的编码,并且网站是 ISO-8859-1..

这里的底线是,我迷路了!如何使这些东西在旧版 php4 上工作?在 php4.. 上使用 unicode 有什么问题吗?

谢谢。

【问题讨论】:

  • 老实说,在 FastCGI 下并行安装 PHP 5.3.3 可能比将此代码移植到不受支持的四年前的 4.x 版本更幸运。
  • 查尔斯其实还不错,只需要找一个像样的,php4支持的XML库就可以了。

标签: php xml legacy php4 domdocument


【解决方案1】:

好吧,我设法做到了——幸运的是,我在ister.org 上找到了 php5 的 simpleXML 函数的反向移植,它在 php4.4 上工作得很好。我重写了很多代码,并不太棘手。

希望这对将来的其他人有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-21
    相关资源
    最近更新 更多