3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MySessionHandler implements \SessionHandlerInterface { public $messages = array(); public function open($savePath, $sessionName) { $this->messages[] = 'open ' . $sessionName; } public function close() { $this->messages[] = 'close'; } public function read($id) { $this->messages[] = 'read ' . $id; } public function write($id, $data) { $this->messages[] = 'write ' . $id . ': ' . $data; throw new \RuntimeException('bad'); } public function destroy($id) { $this->messages[] = 'destroy ' . $id; } public function gc($maxlifetime) { $this->messages[] = 'gc ' . var_export($maxlifetime, true); } public function __destruct() { var_dump($this->messages); } } try { $handler = new MySessionHandler(); session_set_save_handler($handler, true); $handler->messages[] = 'isset($_SESSION): ' . var_export(isset($_SESSION), true); $_SESSION['before'] = 'start'; session_start(); $_SESSION['foo'] = 'bar'; $handler->messages[] = 'current session_id: ' . session_id(); session_regenerate_id(true); $handler->messages[] = 'current session_id: ' . session_id(); session_write_close(); } catch (\Exception $e) { } session_start(); session_destroy(); $handler->messages[] = var_export($_SESSION, true); $handler->messages[] = 'current session_id: ' . var_export(session_id(), true); session_id('explicit-session-id'); session_start(); $_SESSION['john'] = 'doe';
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 43
Branch analysis from position: 43
2 jumps found. (Code = 107) Position 1 = 44, Position 2 = -2
Branch analysis from position: 44
filename:       /in/pkJe4
function name:  (null)
number of ops:  75
compiled vars:  !0 = $handler, !1 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   DECLARE_CLASS                                            'mysessionhandler'
   45     1        NEW                                              $2      'MySessionHandler'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   46     4        INIT_FCALL                                               'session_set_save_handler'
          5        SEND_VAR                                                 !0
          6        SEND_VAL                                                 <true>
          7        DO_ICALL                                                 
   48     8        INIT_FCALL                                               'var_export'
          9        ISSET_ISEMPTY_VAR                             2  ~8      '_SESSION'
         10        SEND_VAL                                                 ~8
         11        SEND_VAL                                                 <true>
         12        DO_ICALL                                         $9      
         13        CONCAT                                           ~10     'isset%28%24_SESSION%29%3A+', $9
         14        FETCH_OBJ_W                                      $6      !0, 'messages'
         15        ASSIGN_DIM                                               $6
         16        OP_DATA                                                  ~10
   49    17        FETCH_W                      global              $11     '_SESSION'
         18        ASSIGN_DIM                                               $11, 'before'
         19        OP_DATA                                                  'start'
   51    20        INIT_FCALL                                               'session_start'
         21        DO_ICALL                                                 
   53    22        FETCH_W                      global              $14     '_SESSION'
         23        ASSIGN_DIM                                               $14, 'foo'
         24        OP_DATA                                                  'bar'
   55    25        INIT_FCALL                                               'session_id'
         26        DO_ICALL                                         $18     
         27        CONCAT                                           ~19     'current+session_id%3A+', $18
         28        FETCH_OBJ_W                                      $16     !0, 'messages'
         29        ASSIGN_DIM                                               $16
         30        OP_DATA                                                  ~19
   56    31        INIT_FCALL                                               'session_regenerate_id'
         32        SEND_VAL                                                 <true>
         33        DO_ICALL                                                 
   57    34        INIT_FCALL                                               'session_id'
         35        DO_ICALL                                         $23     
         36        CONCAT                                           ~24     'current+session_id%3A+', $23
         37        FETCH_OBJ_W                                      $21     !0, 'messages'
         38        ASSIGN_DIM                                               $21
         39        OP_DATA                                                  ~24
   59    40        INIT_FCALL                                               'session_write_close'
         41        DO_ICALL                                                 
         42      > JMP                                                      ->44
   61    43  E > > CATCH                                       last         'Exception'
   63    44    >   INIT_FCALL                                               'session_start'
         45        DO_ICALL                                                 
   64    46        INIT_FCALL                                               'session_destroy'
         47        DO_ICALL                                                 
   66    48        INIT_FCALL                                               'var_export'
         49        FETCH_R                      global              ~30     '_SESSION'
         50        SEND_VAL                                                 ~30
         51        SEND_VAL                                                 <true>
         52        DO_ICALL                                         $31     
         53        FETCH_OBJ_W                                      $28     !0, 'messages'
         54        ASSIGN_DIM                                               $28
         55        OP_DATA                                                  $31
   67    56        INIT_FCALL                                               'var_export'
         57        INIT_FCALL                                               'session_id'
         58        DO_ICALL                                         $34     
         59        SEND_VAR                                                 $34
         60        SEND_VAL                                                 <true>
         61        DO_ICALL                                         $35     
         62        CONCAT                                           ~36     'current+session_id%3A+', $35
         63        FETCH_OBJ_W                                      $32     !0, 'messages'
         64        ASSIGN_DIM                                               $32
         65        OP_DATA                                                  ~36
   69    66        INIT_FCALL                                               'session_id'
         67        SEND_VAL                                                 'explicit-session-id'
         68        DO_ICALL                                                 
   70    69        INIT_FCALL                                               'session_start'
         70        DO_ICALL                                                 
   71    71        FETCH_W                      global              $39     '_SESSION'
         72        ASSIGN_DIM                                               $39, 'john'
         73        OP_DATA                                                  'doe'
         74      > RETURN                                                   1

Class MySessionHandler:
Function open:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pkJe4
function name:  open
number of ops:  7
compiled vars:  !0 = $savePath, !1 = $sessionName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   10     2        CONCAT                                           ~4      'open+', !1
          3        FETCH_OBJ_W                                      $2      'messages'
          4        ASSIGN_DIM                                               $2
          5        OP_DATA                                                  ~4
   11     6      > RETURN                                                   null

End of function open

Function close:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pkJe4
function name:  close
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   FETCH_OBJ_W                                      $0      'messages'
          1        ASSIGN_DIM                                               $0
          2        OP_DATA                                                  'close'
   16     3      > RETURN                                                   null

End of function close

Function read:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pkJe4
function name:  read
number of ops:  6
compiled vars:  !0 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   20     1        CONCAT                                           ~3      'read+', !0
          2        FETCH_OBJ_W                                      $1      'messages'
          3        ASSIGN_DIM                                               $1
          4        OP_DATA                                                  ~3
   21     5      > RETURN                                                   null

End of function read

Function write:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/pkJe4
function name:  write
number of ops:  13
compiled vars:  !0 = $id, !1 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   25     2        CONCAT                                           ~4      'write+', !0
          3        CONCAT                                           ~5      ~4, '%3A+'
          4        CONCAT                                           ~6      ~5, !1
          5        FETCH_OBJ_W                                      $2      'messages'
          6        ASSIGN_DIM                                               $2
          7        OP_DATA                                                  ~6
   26     8        NEW                                              $7      'RuntimeException'
          9        SEND_VAL_EX                                              'bad'
         10        DO_FCALL                                      0          
         11      > THROW                                         0          $7
   27    12*     > RETURN                                                   null

End of function write

Function destroy:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pkJe4
function name:  destroy
number of ops:  6
compiled vars:  !0 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
   31     1        CONCAT                                           ~3      'destroy+', !0
          2        FETCH_OBJ_W                                      $1      'messages'
          3        ASSIGN_DIM                                               $1
          4        OP_DATA                                                  ~3
   32     5      > RETURN                                                   null

End of function destroy

Function gc:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pkJe4
function name:  gc
number of ops:  10
compiled vars:  !0 = $maxlifetime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   RECV                                             !0      
   36     1        INIT_FCALL                                               'var_export'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $3      
          5        CONCAT                                           ~4      'gc+', $3
          6        FETCH_OBJ_W                                      $1      'messages'
          7        ASSIGN_DIM                                               $1
          8        OP_DATA                                                  ~4
   37     9      > RETURN                                                   null

End of function gc

Function __destruct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pkJe4
function name:  __destruct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   INIT_FCALL                                               'var_dump'
          1        FETCH_OBJ_R                                      ~0      'messages'
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                                 
   42     4      > RETURN                                                   null

End of function __destruct

End of class MySessionHandler.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.54 ms | 1400 KiB | 29 Q