<?php
class UserNotFoundException extends \Exception {}
function check_user_exists($user_id)
{
// check user account hasn't been deleted, otherwise throw:
throw new UserNotFoundException("exceptions for flow control are great.\n");
}
class User
{
private $id = 5;
function __unserialize(array $data) {
check_user_exists($data["\x00User\x00id"]);
}
}
$user = new User();
$data = serialize($user);
echo "$data \n";
try {
$result = unserialize($data);
}
catch (UserNotFoundException $unfe) {
echo "redirect user to login page\n";
exit(0);
}
echo "User is valid.\n";
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/YQFXH on line 3
O:4:"User":1:{s:8:" User id";i:5;}
User is valid.
Output for 5.0.0 - 5.0.5
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/YQFXH on line 3
Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in /in/YQFXH on line 15
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/YQFXH on line 3
Parse error: syntax error, unexpected T_NEW in /in/YQFXH on line 8
Process exited with code 255.
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/YQFXH on line 3
Parse error: parse error, unexpected T_NEW in /in/YQFXH on line 8
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/YQFXH on line 3
Parse error: parse error in /in/YQFXH on line 8
Process exited with code 255.