2010-08-17 51 views
0

我试图让一些我的php5代码在遗留服务器上工作,遗憾的是无法升级(客户端机器)。将PHP5移植到传统PHP4,DOMDocument qu 012

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; 
      } 


     } 
    } 

} 

据我已经得到了作为工作的是DOM文档中缺少PHP4一吨的方法(它的php4.4.4,在CentOS的盒子),其中一些似乎是由全球静态函数来代替。 ...。 domxml_open_file()? XML也有UTF8的编码,并且该网站在ISO-8859-1中。

这里的底线是,我迷路了!如何使这个东西在传统的php4上工作?有没有关于在php4上使用unicode的问题..?

谢谢。

+0

老实说,在FastCGI下进行PHP 5.3.3的并行安装比将此代码移植到不支持的4年旧版4.x版本上可能会更好。 – Charles 2010-08-17 16:15:34

+0

不是一个选项,可悲的是.. – dmp 2010-08-17 16:26:52

+0

其实并没有那么糟糕查尔斯,只需要找到一个体面的XML库支持php4。 – dmp 2010-08-19 09:58:46

回答

1

嗯,我设法得到了这个 - 幸运的是,我在ister.org上找到了一个php5的simpleXML函数的后端,它在php4.4上工作得很好。我已经重写了很多代码,并且它不是太棘手。

希望这可以帮助别人在未来。