3v4l.org

run code in 300+ PHP versions simultaneously
<?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";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 15
Branch analysis from position: 15
2 jumps found. (Code = 107) Position 1 = 16, Position 2 = -2
Branch analysis from position: 16
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/YQFXH
function name:  (null)
number of ops:  20
compiled vars:  !0 = $user, !1 = $data, !2 = $result, !3 = $unfe
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   NEW                                              $4      'User'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $4
   22     3        INIT_FCALL                                               'serialize'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $7      
          6        ASSIGN                                                   !1, $7
   24     7        NOP                                                      
          8        FAST_CONCAT                                      ~9      !1, '+%0A'
          9        ECHO                                                     ~9
   27    10        INIT_FCALL                                               'unserialize'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                         $10     
         13        ASSIGN                                                   !2, $10
         14      > JMP                                                      ->18
   30    15  E > > CATCH                                       last         'UserNotFoundException'
   31    16    >   ECHO                                                     'redirect+user+to+login+page%0A'
   32    17      > EXIT                                                     0
   35    18    >   ECHO                                                     'User+is+valid.%0A'
         19      > RETURN                                                   1

Function check_user_exists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/YQFXH
function name:  check_user_exists
number of ops:  6
compiled vars:  !0 = $user_id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    8     1        NEW                                              $1      'UserNotFoundException'
          2        SEND_VAL_EX                                              'exceptions+for+flow+control+are+great.%0A'
          3        DO_FCALL                                      0          
          4      > THROW                                         0          $1
    9     5*     > RETURN                                                   null

End of function check_user_exists

Class UserNotFoundException: [no user functions]
Class User:
Function __unserialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YQFXH
function name:  __unserialize
number of ops:  6
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   16     1        INIT_FCALL                                               'check_user_exists'
          2        FETCH_DIM_R                                      ~1      !0, '%00User%00id'
          3        SEND_VAL                                                 ~1
          4        DO_FCALL                                      0          
   17     5      > RETURN                                                   null

End of function __unserialize

End of class User.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
186.98 ms | 1407 KiB | 18 Q