serialization - Serializing anonymous functions in php -
is there way serialize anonymous function in php?
i have found http://www.htmlist.com/development/extending-php-5-3-closures-with-serialization-and-reflection/
protected function _fetchcode() { // open file , seek first line of closure $file = new splfileobject($this->reflection->getfilename()); $file->seek($this->reflection->getstartline()-1); // retrieve of lines contain code closure $code = ''; while ($file->key() < $this->reflection->getendline()) { $code .= $file->current(); $file->next(); } // keep code defining closure $begin = strpos($code, 'function'); $end = strrpos($code, '}'); $code = substr($code, $begin, $end - $begin + 1); return $code; }
but depends on internal implementation of closure.
are there future plans implement closure serialization?
take response here php super closure :
exception: serialization of 'closure' not allowed
i hope helps.
Comments
Post a Comment