<?php
class Foo {
public function __wakeup() {
echo 'In foo', PHP_EOL, PHP_EOL;
throw new \Exception('Foo');
}
public function __destruct() {
echo 'Destruct foo', PHP_EOL, PHP_EOL;
throw new \Exception('Foo destruct');
}
}
class Bar {
public function __wakeup() {
echo 'In bar', PHP_EOL, PHP_EOL;
throw new \Exception('Bar');
}
public function __destruct() {
echo 'Destruct bar', PHP_EOL, PHP_EOL;
throw new \Exception('Bar destruct');
}
}
try {
unserialize(serialize([$f = new Foo, $b = new Bar]));
} catch (\Throwable $e) {
echo $e, PHP_EOL, PHP_EOL;
}
echo "==========", PHP_EOL, PHP_EOL;
try {
unserialize(serialize([$b, $f]));
} catch (\Throwable $e) {
echo $e, PHP_EOL, PHP_EOL;
}
preferences:
49.57 ms | 402 KiB | 5 Q