显然匿名函数不能序列化。
例
$function = function () {
return "ABC";
};
serialize($function); // would throw error
从你的代码,你使用Closure
$callback = function () //
{
return 'ZendMail_' . microtime(true) . '.tmp';
};
解决方案1:用正常函数替换示例
function emailCallback() {
return 'ZendMail_' . microtime(true) . '.tmp';
}
$callback = "emailCallback" ;
解决方案2:通过数组变量调用间接方法
public function __construct($options = null)
63 {
64 if ($options instanceof Zend_Config) {
65 $options = $options->toArray();
66 } elseif (!is_array($options)) {
67 $options = array();
68 }
69
70 // Making sure we have some defaults to work with
71 if (!isset($options['path'])) {
72 $options['path'] = sys_get_temp_dir();
73 }
74 if (!isset($options['callback'])) {
75 $options['callback'] = array($this, 'defaultCallback');
76 }
77
78 $this->setOptions($options);
79 }
您可以使用相同的方法发送回调
$callback = array($this,"aMethodInYourClass");