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; } 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); } } $handler = new MySessionHandler(); echo 'SS'; session_regenerate_id(); die(); $handler->messages[] = 'session_status(): ' . session_status(); $handler->messages[] = 'session_id before start: ' . var_export(session_id(), true); 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(); $handler->messages[] = '$_SESSION after close: ' . var_export($_SESSION, true); $handler->messages[] = 'session_id after close: ' . session_id(); session_start(); session_destroy(); $handler->messages[] = '$_SESSION after destroy: ' . 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 = 79) Position 1 = -2
filename:       /in/d8UWL
function name:  (null)
number of ops:  109
compiled vars:  !0 = $handler
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   DECLARE_CLASS                                            'mysessionhandler'
   47     1        NEW                                              $1      'MySessionHandler'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   48     4        ECHO                                                     'SS'
   49     5        INIT_FCALL                                               'session_regenerate_id'
          6        DO_ICALL                                                 
   50     7      > EXIT                                                     
   51     8*       INIT_FCALL                                               'session_status'
          9*       DO_ICALL                                         $7      
         10*       CONCAT                                           ~8      'session_status%28%29%3A+', $7
         11*       FETCH_OBJ_W                                      $5      !0, 'messages'
         12*       ASSIGN_DIM                                               $5
         13*       OP_DATA                                                  ~8
   52    14*       INIT_FCALL                                               'var_export'
         15*       INIT_FCALL                                               'session_id'
         16*       DO_ICALL                                         $11     
         17*       SEND_VAR                                                 $11
         18*       SEND_VAL                                                 <true>
         19*       DO_ICALL                                         $12     
         20*       CONCAT                                           ~13     'session_id+before+start%3A+', $12
         21*       FETCH_OBJ_W                                      $9      !0, 'messages'
         22*       ASSIGN_DIM                                               $9
         23*       OP_DATA                                                  ~13
   53    24*       INIT_FCALL                                               'session_set_save_handler'
         25*       SEND_VAR                                                 !0
         26*       SEND_VAL                                                 <true>
         27*       DO_ICALL                                                 
   55    28*       INIT_FCALL                                               'var_export'
         29*       ISSET_ISEMPTY_VAR                             2  ~17     '_SESSION'
         30*       SEND_VAL                                                 ~17
         31*       SEND_VAL                                                 <true>
         32*       DO_ICALL                                         $18     
         33*       CONCAT                                           ~19     'isset%28%24_SESSION%29%3A+', $18
         34*       FETCH_OBJ_W                                      $15     !0, 'messages'
         35*       ASSIGN_DIM                                               $15
         36*       OP_DATA                                                  ~19
   56    37*       FETCH_W                      global              $20     '_SESSION'
         38*       ASSIGN_DIM                                               $20, 'before'
         39*       OP_DATA                                                  'start'
   58    40*       INIT_FCALL                                               'session_start'
         41*       DO_ICALL                                                 
   60    42*       FETCH_W                      global              $23     '_SESSION'
         43*       ASSIGN_DIM                                               $23, 'foo'
         44*       OP_DATA                                                  'bar'
   62    45*       INIT_FCALL                                               'session_id'
         46*       DO_ICALL                                         $27     
         47*       CONCAT                                           ~28     'current+session_id%3A+', $27
         48*       FETCH_OBJ_W                                      $25     !0, 'messages'
         49*       ASSIGN_DIM                                               $25
         50*       OP_DATA                                                  ~28
   63    51*       INIT_FCALL                                               'session_regenerate_id'
         52*       SEND_VAL                                                 <true>
         53*       DO_ICALL                                                 
   64    54*       INIT_FCALL                                               'session_id'
         55*       DO_ICALL                                         $32     
         56*       CONCAT                                           ~33     'current+session_id%3A+', $32
         57*       FETCH_OBJ_W                                      $30     !0, 'messages'
         58*       ASSIGN_DIM                                               $30
         59*       OP_DATA                                                  ~33
   65    60*       INIT_FCALL                                               'session_write_close'
         61*       DO_ICALL                                                 
   67    62*       INIT_FCALL                                               'var_export'
         63*       FETCH_R                      global              ~37     '_SESSION'
         64*       SEND_VAL                                                 ~37
         65*       SEND_VAL                                                 <true>
         66*       DO_ICALL                                         $38     
         67*       CONCAT                                           ~39     '%24_SESSION+after+close%3A+', $38
         68*       FETCH_OBJ_W                                      $35     !0, 'messages'
         69*       ASSIGN_DIM                                               $35
         70*       OP_DATA                                                  ~39
   68    71*       INIT_FCALL                                               'session_id'
         72*       DO_ICALL                                         $42     
         73*       CONCAT                                           ~43     'session_id+after+close%3A+', $42
         74*       FETCH_OBJ_W                                      $40     !0, 'messages'
         75*       ASSIGN_DIM                                               $40
         76*       OP_DATA                                                  ~43
   70    77*       INIT_FCALL                                               'session_start'
         78*       DO_ICALL                                                 
   71    79*       INIT_FCALL                                               'session_destroy'
         80*       DO_ICALL                                                 
   72    81*       INIT_FCALL                                               'var_export'
         82*       FETCH_R                      global              ~48     '_SESSION'
         83*       SEND_VAL                                                 ~48
         84*       SEND_VAL                                                 <true>
         85*       DO_ICALL                                         $49     
         86*       CONCAT                                           ~50     '%24_SESSION+after+destroy%3A+', $49
         87*       FETCH_OBJ_W                                      $46     !0, 'messages'
         88*       ASSIGN_DIM                                               $46
         89*       OP_DATA                                                  ~50
   73    90*       INIT_FCALL                                               'var_export'
         91*       INIT_FCALL                                               'session_id'
         92*       DO_ICALL                                         $53     
         93*       SEND_VAR                                                 $53
         94*       SEND_VAL                                                 <true>
         95*       DO_ICALL                                         $54     
         96*       CONCAT                                           ~55     'current+session_id%3A+', $54
         97*       FETCH_OBJ_W                                      $51     !0, 'messages'
         98*       ASSIGN_DIM                                               $51
         99*       OP_DATA                                                  ~55
   75   100*       INIT_FCALL                                               'session_id'
        101*       SEND_VAL                                                 'explicit-session-id'
        102*       DO_ICALL                                                 
   76   103*       INIT_FCALL                                               'session_start'
        104*       DO_ICALL                                                 
   77   105*       FETCH_W                      global              $58     '_SESSION'
        106*       ASSIGN_DIM                                               $58, 'john'
        107*       OP_DATA                                                  'doe'
        108*     > RETURN                                                   1

Class MySessionHandler:
Function open:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/d8UWL
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/d8UWL
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/d8UWL
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 = 62) Position 1 = -2
filename:       /in/d8UWL
function name:  write
number of ops:  9
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      > 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/d8UWL
function name:  destroy
number of ops:  6
compiled vars:  !0 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
   30     1        CONCAT                                           ~3      'destroy+', !0
          2        FETCH_OBJ_W                                      $1      'messages'
          3        ASSIGN_DIM                                               $1
          4        OP_DATA                                                  ~3
   31     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/d8UWL
function name:  gc
number of ops:  10
compiled vars:  !0 = $maxlifetime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
   35     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
   36     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/d8UWL
function name:  __destruct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   INIT_FCALL                                               'var_dump'
          1        FETCH_OBJ_R                                      ~0      'messages'
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                                 
   41     4      > RETURN                                                   null

End of function __destruct

End of class MySessionHandler.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.12 ms | 1412 KiB | 31 Q