Coolweather_rpc中XMLParser对PHP版本的兼容问题

  从 andot 的网站上找到一个不错的WP插件 coolweather,就是我页面右边那个Weather的东西,利用PHPRpc实现Ajax从 accuweather 的xml接口读取天气信息,经过解析和处理后显示到页面上,是个非常不错的插件。

  在andot写的插件中如果使用到了PHPRpc Server,默认都是在代码里面指向使用他服务器上的PHPRpc Server,这给很多朋友提供了方便,不过也给andot的服务器形成较大压力,导致最近总是服务器无法访问,也就致使andot提供的PHPRpc Server没法连接,也就无法正常返回Weather数据,于是我决定改到使用我自己服务器上的PHPRpc Server,却遇到一点麻烦。

  Coolweather_rpc中用到了xml解析类,这个类据andot说不是他自己写的,从国外下载过来直接使用的,简单的看了一下代码,发现代码并不复杂,但是感觉解析效率并不是很高,简单的xml数据会占用较大的系统开销,不过由于weather数据实在不大,加上访问压力并不大,就先凑合用着吧,等空了改成我原来在3721自己写的一个XML解析类。经过我实际使用,发现这个xml解析类还有个怪现象,那就是在兼容PHP4.x和5.x版本时有问题,最初的现象就是在我的本本上没有问题,上次到toplee服务器上就不能正常解析,让我花了很多时间去定位和排查代码对Windows和FreeBSD的兼容性问题,没想最后发现是因为在toplee服务器上的php.ini中我打开了这样一个选项
[coolcode linenum=”off”]
; Enable compatibility mode with Zend Engine 1 (PHP 4.x)
zend.ze1_compatibility_mode = On
[/coolcode]
  就是这个设置导致了问题,我给改成Off或者把xml_parser.php文件代码改成强制使用xml_parser_php4.php后就没有问题了。

  虽然简单的解决了问题,但是我感觉这个问题应当成为一个普遍的问题提出来考虑,那就是当我们服务器环境要求同时兼容PHP4.x和5.x的时候,代码中应该注意一些什么呢?初步的感觉应该从5.x和4.x的差异入手,有时间专门研究一下,整理一份东西出来今后备用。

3 thoughts on “Coolweather_rpc中XMLParser对PHP版本的兼容问题”

  1. hello,

    can you help me find an english website explaining how I can start using my own rpc server instead of relying on coolcode’s server?

    I remember reading somewhere reading that was possible, but all I can find with google now is chinese or other asian language I don’t udnerstand.

    would be great if you could help

    thx
    ovidiu

  2. Hello there! I know this is kinda off topic however I’d figured I’d ask.
    Would you be interested in exchanging links or maybe guest writing a blog post or vice-versa?
    My site addresses a lot of the same subjects as yours and I think we
    could greatly benefit from each other. If you are interested feel free to
    send me an email. I look forward to hearing from you!
    Fantastic blog by the way!

  3. Pingback: design,
  4. I know this if off topic but I’m looking into starting my own weblog and was wondering what all is required
    to get set up? I’m assuming having a blog like yours would cost a
    pretty penny? I’m not very internet smart so I’m not 100% certain. Any tips or advice would be greatly appreciated.

    Cheers

  5. With havin so much written content do you ever run into any
    issues of plagorism or copyright violation? My blog has a lot of completely unique content I’ve
    either written myself or outsourced but it looks like a lot of
    it is popping it up all over the internet without my permission. Do you know any solutions to help prevent content from
    being ripped off? I’d genuinely appreciate it.

  6. Hey just wanted to give you a quick heads up. The words in your article seem to
    be running off the screen in Ie. I’m not
    sure if this is a format issue or something to do with internet browser compatibility but I figured I’d
    post to let you know. The layout look great though!
    Hope you get the issue fixed soon. Many thanks

  7. Hiya! Quick question that’s totally off topic. Do you know how
    to make your site mobile friendly? My website looks weird when viewing from my iphone.
    I’m trying to find a template or plugin that might be able
    to resolve this problem. If you have any suggestions, please share.
    Cheers!

  8. I must thank you for the efforts you have put in penning this site.
    I am hoping to view the same high-grade blog posts by you later on as well.
    In fact, your creative writing abilities has encouraged me to get
    my own blog now 😉

Leave a Reply

Your email address will not be published. Required fields are marked *

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Anti-spam image