Unserialize in Java a serialized php object

前端 未结 15 1042
闹比i
闹比i 2020-11-29 11:31

Does anyone know if it is possible, actually if it has been done, to serialize an object in php and unserialize it in Java (java-php communication). Maybe an adapter will be

15条回答
  •  粉色の甜心
    2020-11-29 11:39

    Theoretically, it's certainly possible. It's just bytes after all, and they can be parsed. Of course, the deserialized object would contain only data, not any of the PHP methods. If you want that, you'd have to rewrite the behaviour as Java classes that correspond directly with the PHP classes.

    In practice, the main problem seems to be that the PHP serialization format does not seem to be formally specified - at least there is no link to a specification in the manual.

    So you might have to dig through the code to understand the format.

    All in all, it sounds like it would be much easier and more stable to use something like XML serialization - I'm sure both languages have libraries that faciliate this.

提交回复
热议问题