7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
16 * @package Zend_Serializer
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
23 /** @see Zend_Serializer_Adapter_AdapterAbstract */
24 require_once 'Zend/Serializer/Adapter/AdapterAbstract.php';
28 * @package Zend_Serializer
30 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
31 * @license http://framework.zend.com/license/new-bsd New BSD License
33 class Zend_Serializer_Adapter_PhpSerialize
extends Zend_Serializer_Adapter_AdapterAbstract
36 * @var null|string Serialized boolean false value
38 private static $_serializedFalse = null;
43 * @param array|Zend_Config $opts
46 public function __construct($opts = array())
48 parent
::__construct($opts);
50 if (self
::$_serializedFalse === null) {
51 self
::$_serializedFalse = serialize(false);
56 * Serialize using serialize()
61 * @throws Zend_Serializer_Exception On serialize error
63 public function serialize($value, array $opts = array())
65 $ret = serialize($value);
67 $lastErr = error_get_last();
68 require_once 'Zend/Serializer/Exception.php';
69 throw new Zend_Serializer_Exception($lastErr['message']);
77 * @todo Allow integration with unserialize_callback_func
78 * @param string $serialized
81 * @throws Zend_Serializer_Exception on unserialize error
83 public function unserialize($serialized, array $opts = array())
85 // TODO: @see php.ini directive "unserialize_callback_func"
86 $ret = @unserialize
($serialized);
87 if ($ret === false && $serialized !== self
::$_serializedFalse) {
88 $lastErr = error_get_last();
89 require_once 'Zend/Serializer/Exception.php';
90 throw new Zend_Serializer_Exception($lastErr['message']);