【发布时间】: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