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(); $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'; $handler->messages[] = 'headers_sent: ' . var_export(headers_sent(), true); header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); session_start(); $handler->messages[] = 'headers_sent: ' . var_export(headers_sent(), true); $handler->messages[] = 'headers_list: ' . var_export(headers_list(), true); $_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 = 62) Position 1 = -2
filename:       /in/jEmbF
function name:  (null)
number of ops:  138
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                                               'var_export'
         11        INIT_FCALL                                               'session_id'
         12        DO_ICALL                                         $10     
         13        SEND_VAR                                                 $10
         14        SEND_VAL                                                 <true>
         15        DO_ICALL                                         $11     
         16        CONCAT                                           ~12     'session_id+before+start%3A+', $11
         17        FETCH_OBJ_W                                      $8      !0, 'messages'
         18        ASSIGN_DIM                                               $8
         19        OP_DATA                                                  ~12
   48    20        INIT_FCALL                                               'session_set_save_handler'
         21        SEND_VAR                                                 !0
         22        SEND_VAL                                                 <true>
         23        DO_ICALL                                                 
   50    24        INIT_FCALL                                               'var_export'
         25        ISSET_ISEMPTY_VAR                             2  ~16     '_SESSION'
         26        SEND_VAL                                                 ~16
         27        SEND_VAL                                                 <true>
         28        DO_ICALL                                         $17     
         29        CONCAT                                           ~18     'isset%28%24_SESSION%29%3A+', $17
         30        FETCH_OBJ_W                                      $14     !0, 'messages'
         31        ASSIGN_DIM                                               $14
         32        OP_DATA                                                  ~18
   51    33        FETCH_W                      global              $19     '_SESSION'
         34        ASSIGN_DIM                                               $19, 'before'
         35        OP_DATA                                                  'start'
   53    36        INIT_FCALL                                               'var_export'
         37        INIT_FCALL                                               'headers_sent'
         38        DO_ICALL                                         $23     
         39        SEND_VAR                                                 $23
         40        SEND_VAL                                                 <true>
         41        DO_ICALL                                         $24     
         42        CONCAT                                           ~25     'headers_sent%3A+', $24
         43        FETCH_OBJ_W                                      $21     !0, 'messages'
         44        ASSIGN_DIM                                               $21
         45        OP_DATA                                                  ~25
   54    46        INIT_FCALL                                               'header'
         47        SEND_VAL                                                 'Expires%3A+Sat%2C+26+Jul+1997+05%3A00%3A00+GMT'
         48        DO_ICALL                                                 
   55    49        INIT_FCALL                                               'session_start'
         50        DO_ICALL                                                 
   57    51        INIT_FCALL                                               'var_export'
         52        INIT_FCALL                                               'headers_sent'
         53        DO_ICALL                                         $30     
         54        SEND_VAR                                                 $30
         55        SEND_VAL                                                 <true>
         56        DO_ICALL                                         $31     
         57        CONCAT                                           ~32     'headers_sent%3A+', $31
         58        FETCH_OBJ_W                                      $28     !0, 'messages'
         59        ASSIGN_DIM                                               $28
         60        OP_DATA                                                  ~32
   58    61        INIT_FCALL                                               'var_export'
         62        INIT_FCALL                                               'headers_list'
         63        DO_ICALL                                         $35     
         64        SEND_VAR                                                 $35
         65        SEND_VAL                                                 <true>
         66        DO_ICALL                                         $36     
         67        CONCAT                                           ~37     'headers_list%3A+', $36
         68        FETCH_OBJ_W                                      $33     !0, 'messages'
         69        ASSIGN_DIM                                               $33
         70        OP_DATA                                                  ~37
   60    71        FETCH_W                      global              $38     '_SESSION'
         72        ASSIGN_DIM                                               $38, 'foo'
         73        OP_DATA                                                  'bar'
   62    74        INIT_FCALL                                               'session_id'
         75        DO_ICALL                                         $42     
         76        CONCAT                                           ~43     'current+session_id%3A+', $42
         77        FETCH_OBJ_W                                      $40     !0, 'messages'
         78        ASSIGN_DIM                                               $40
         79        OP_DATA                                                  ~43
   63    80        INIT_FCALL                                               'session_regenerate_id'
         81        SEND_VAL                                                 <true>
         82        DO_ICALL                                                 
   64    83        INIT_FCALL                                               'session_id'
         84        DO_ICALL                                         $47     
         85        CONCAT                                           ~48     'current+session_id%3A+', $47
         86        FETCH_OBJ_W                                      $45     !0, 'messages'
         87        ASSIGN_DIM                                               $45
         88        OP_DATA                                                  ~48
   65    89        INIT_FCALL                                               'session_write_close'
         90        DO_ICALL                                                 
   67    91        INIT_FCALL                                               'var_export'
         92        FETCH_R                      global              ~52     '_SESSION'
         93        SEND_VAL                                                 ~52
         94        SEND_VAL                                                 <true>
         95        DO_ICALL                                         $53     
         96        CONCAT                                           ~54     '%24_SESSION+after+close%3A+', $53
         97        FETCH_OBJ_W                                      $50     !0, 'messages'
         98        ASSIGN_DIM                                               $50
         99        OP_DATA                                                  ~54
   68   100        INIT_FCALL                                               'session_id'
        101        DO_ICALL                                         $57     
        102        CONCAT                                           ~58     'session_id+after+close%3A+', $57
        103        FETCH_OBJ_W                                      $55     !0, 'messages'
        104        ASSIGN_DIM                                               $55
        105        OP_DATA                                                  ~58
   70   106        INIT_FCALL                                               'session_start'
        107        DO_ICALL                                                 
   71   108        INIT_FCALL                                               'session_destroy'
        109        DO_ICALL                                                 
   72   110        INIT_FCALL                                               'var_export'
        111        FETCH_R                      global              ~63     '_SESSION'
        112        SEND_VAL                                                 ~63
        113        SEND_VAL                                                 <true>
        114        DO_ICALL                                         $64     
        115        CONCAT                                           ~65     '%24_SESSION+after+destroy%3A+', $64
        116        FETCH_OBJ_W                                      $61     !0, 'messages'
        117        ASSIGN_DIM                                               $61
        118        OP_DATA                                                  ~65
   73   119        INIT_FCALL                                               'var_export'
        120        INIT_FCALL                                               'session_id'
        121        DO_ICALL                                         $68     
        122        SEND_VAR                                                 $68
        123        SEND_VAL                                                 <true>
        124        DO_ICALL                                         $69     
        125        CONCAT                                           ~70     'current+session_id%3A+', $69
        126        FETCH_OBJ_W                                      $66     !0, 'messages'
        127        ASSIGN_DIM                                               $66
        128        OP_DATA                                                  ~70
   75   129        INIT_FCALL                                               'session_id'
        130        SEND_VAL                                                 'explicit-session-id'
        131        DO_ICALL                                                 
   76   132        INIT_FCALL                                               'session_start'
        133        DO_ICALL                                                 
   77   134        FETCH_W                      global              $73     '_SESSION'
        135        ASSIGN_DIM                                               $73, 'john'
        136        OP_DATA                                                  'doe'
        137      > RETURN                                                   1

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