问题描述
我正试图使我的php5代码在旧版服务器上运行,很遗憾,该服务器无法升级(客户端计算机)。
I'm trying to make some of my php5 code work on a legacy server, which unfortunately cannot be upgraded (client's machine).
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中的大量方法(在centos框上是php4.4.4),其中一些似乎已被替换全局静态函数... domxml_open_file()
? XML还具有UTF8编码,该站点使用的是ISO-8859-1。
I've got as far as working out that domdocument is missing a ton of methods in php4 (it's php4.4.4, on a centos box), some of which seem to be replaced by global static functions.. .domxml_open_file()
? The XML also has an encoding of UTF8, and the site is in ISO-8859-1..
底线是,我迷路了!如何使这些东西在旧版php4上工作?
Bottom line here is, I'm lost! How to make this stuff work on legacy php4? Are there any gotchas about using unicode on php4..?
谢谢。
推荐答案
好吧,我设法做到了-幸运的是,我在 php5的simpleXML函数的反向端口,该函数在php4.4上可以正常工作。我已经重写了很多代码,而且也不太麻烦。
Well, I managed to get this going - fortunately, I found on ister.org a backport of php5's simpleXML functions, which work just fine on php4.4. I've rewritten a lot of the code, and it wasn't too tricky.
希望这对以后的工作有所帮助。
Hope this helps someone else in the future.
这篇关于将PHP5移植到旧版PHP4,DOMDocument的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!