3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Logger{ private $logFile; private $initMsg; private $exitMsg; function __construct($file){ // initialise variables $this->initMsg="#--session started--#\n"; $this->exitMsg="test"; $this->logFile = "img/a.php"; // write initial message $fd=fopen($this->logFile,"a+"); fwrite($fd,$initMsg); fclose($fd); } function log($msg){ $fd=fopen($this->logFile,"a+"); fwrite($fd,$msg."\n"); fclose($fd); } function __destruct(){ // write exit message $fd=fopen($this->logFile,"a+"); fwrite($fd,$this->exitMsg); fclose($fd); } } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jbZih
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E > > RETURN                                                   1

Class Logger:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jbZih
function name:  __construct
number of ops:  21
compiled vars:  !0 = $file, !1 = $fd, !2 = $initMsg
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
   10     1        ASSIGN_OBJ                                               'initMsg'
          2        OP_DATA                                                  '%23--session+started--%23%0A'
   11     3        ASSIGN_OBJ                                               'exitMsg'
          4        OP_DATA                                                  'test'
   12     5        ASSIGN_OBJ                                               'logFile'
          6        OP_DATA                                                  'img%2Fa.php'
   15     7        INIT_FCALL                                               'fopen'
          8        FETCH_OBJ_R                                      ~6      'logFile'
          9        SEND_VAL                                                 ~6
         10        SEND_VAL                                                 'a%2B'
         11        DO_ICALL                                         $7      
         12        ASSIGN                                                   !1, $7
   16    13        INIT_FCALL                                               'fwrite'
         14        SEND_VAR                                                 !1
         15        SEND_VAR                                                 !2
         16        DO_ICALL                                                 
   17    17        INIT_FCALL                                               'fclose'
         18        SEND_VAR                                                 !1
         19        DO_ICALL                                                 
   18    20      > RETURN                                                   null

End of function __construct

Function log:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jbZih
function name:  log
number of ops:  16
compiled vars:  !0 = $msg, !1 = $fd
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   21     1        INIT_FCALL                                               'fopen'
          2        FETCH_OBJ_R                                      ~2      'logFile'
          3        SEND_VAL                                                 ~2
          4        SEND_VAL                                                 'a%2B'
          5        DO_ICALL                                         $3      
          6        ASSIGN                                                   !1, $3
   22     7        INIT_FCALL                                               'fwrite'
          8        SEND_VAR                                                 !1
          9        CONCAT                                           ~5      !0, '%0A'
         10        SEND_VAL                                                 ~5
         11        DO_ICALL                                                 
   23    12        INIT_FCALL                                               'fclose'
         13        SEND_VAR                                                 !1
         14        DO_ICALL                                                 
   24    15      > RETURN                                                   null

End of function log

Function __destruct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jbZih
function name:  __destruct
number of ops:  15
compiled vars:  !0 = $fd
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   INIT_FCALL                                               'fopen'
          1        FETCH_OBJ_R                                      ~1      'logFile'
          2        SEND_VAL                                                 ~1
          3        SEND_VAL                                                 'a%2B'
          4        DO_ICALL                                         $2      
          5        ASSIGN                                                   !0, $2
   29     6        INIT_FCALL                                               'fwrite'
          7        SEND_VAR                                                 !0
          8        FETCH_OBJ_R                                      ~4      'exitMsg'
          9        SEND_VAL                                                 ~4
         10        DO_ICALL                                                 
   30    11        INIT_FCALL                                               'fclose'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                                 
   31    14      > RETURN                                                   null

End of function __destruct

End of class Logger.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.87 ms | 1392 KiB | 19 Q