文字

Serializable::serialize

(PHP 5 >= 5.1.0)

Serializable::serialize对象的字符串表示

说明

abstract public string Serializable::serialize ( void )

返回对象的字符串表示。

Note:

这个方法担当着对象析构器的角色。在此方法之后,__destruct() 方法将不会被调用。

参数

此函数没有参数。

返回值

返回对象的字符串表示或者 NULL

错误/异常

如果返回除了字符串或 NULL 之外的其他类型,将抛出 Exception。

参见

  • __sleep()

用户评论:

[#1] crog at gustavus dot edu [2013-11-07 17:30:19]

The documentation here is somewhat misleading. Where it says "This method acts as the destructor of the object. The __destruct() method will not be called after this method," I believe the intent is not that the destructor is not run on the object itself, but that the destructor is not called /as part of the serialization process/. 

That is, the object will still be destructed as it goes out of scope as normal, but the destructor is not called as a part of the object's serialization.

上一篇: 下一篇: