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

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