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

Class MySessionHandler:
Function open:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ol3GF
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/ol3GF
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/ol3GF
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/ol3GF
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/ol3GF
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/ol3GF
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/ol3GF
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:
157.17 ms | 1408 KiB | 31 Q