Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

--TEST-- Bug #14293 (serialize() and __sleep()) --FILE-- <?php class t { function __co..

Decoded Output download

--TEST--
Bug #14293 (serialize() and __sleep())
--FILE--
<?php
class t
{
    function __construct()
    {
        $this->a = 'hello';
    }

    function __sleep()
    {
        echo "__sleep called
";
        return array('a','b');
    }
}

$t = new t();
$data = serialize($t);
echo "$data
";
$t = unserialize($data);
var_dump($t);

?>
--EXPECTF--
__sleep called

Warning: serialize(): "b" returned as member variable from __sleep() but does not exist in %s on line %d
O:1:"t":1:{s:1:"a";s:5:"hello";}
object(t)#%d (1) {
  ["a"]=>
  string(5) "hello"
}

Did this file decode correctly?

Original Code

--TEST--
Bug #14293 (serialize() and __sleep())
--FILE--
<?php
class t
{
    function __construct()
    {
        $this->a = 'hello';
    }

    function __sleep()
    {
        echo "__sleep called\n";
        return array('a','b');
    }
}

$t = new t();
$data = serialize($t);
echo "$data\n";
$t = unserialize($data);
var_dump($t);

?>
--EXPECTF--
__sleep called

Warning: serialize(): "b" returned as member variable from __sleep() but does not exist in %s on line %d
O:1:"t":1:{s:1:"a";s:5:"hello";}
object(t)#%d (1) {
  ["a"]=>
  string(5) "hello"
}

Function Calls

None

Variables

None

Stats

MD5 e04af70449c44d1915a1044d4c61029c
Eval Count 0
Decode Time 100 ms