3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Get 10mb of data from /dev/zero try { $infp = fopen('/dev/zero', 'r'); $data = fread($infp, 1024 * 1024 * 1); } finally { if (isset($infp) && $infp !== false) { echo "closing!"; fclose($infp); } } write_data($data); echo "Peak memory usage: ", number_format(memory_get_peak_usage()), " bytes\n"; /** * Bad example of how to write some data to /dev/null */ function write_data($data) { $outfp = fopen('/dev/null', 'w'); fwrite($outfp, $data); fwrite($outfp, "\n"); fclose($outfp); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 162) Position 1 = 12, Position 2 = 11
Branch analysis from position: 12
2 jumps found. (Code = 46) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
1 jumps found. (Code = 163) Position 1 = -2
Branch analysis from position: 21
Branch analysis from position: 16
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0Qnh4
function name:  (null)
number of ops:  34
compiled vars:  !0 = $infp, !1 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   INIT_FCALL                                               'fopen'
          1        SEND_VAL                                                 '%2Fdev%2Fzero'
          2        SEND_VAL                                                 'r'
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !0, $3
    7     5        INIT_FCALL                                               'fread'
          6        SEND_VAR                                                 !0
          7        SEND_VAL                                                 1048576
          8        DO_ICALL                                         $5      
          9        ASSIGN                                                   !1, $5
   10    10      > FAST_CALL                                                ->12
         11    > > JMP                                                      ->22
   11    12    >   ISSET_ISEMPTY_CV                                 ~7      !0
         13      > JMPZ_EX                                          ~7      ~7, ->16
         14    >   TYPE_CHECK                                  1018  ~8      !0
         15        BOOL                                             ~7      ~8
         16    > > JMPZ                                                     ~7, ->21
   13    17    >   ECHO                                                     'closing%21'
   14    18        INIT_FCALL                                               'fclose'
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                                 
         21    > > FAST_RET                                                 
   18    22    >   INIT_FCALL_BY_NAME                                       'write_data'
         23        SEND_VAR_EX                                              !1
         24        DO_FCALL                                      0          
   19    25        ECHO                                                     'Peak+memory+usage%3A+'
         26        INIT_FCALL                                               'number_format'
         27        INIT_FCALL                                               'memory_get_peak_usage'
         28        DO_ICALL                                         $11     
         29        SEND_VAR                                                 $11
         30        DO_ICALL                                         $12     
         31        ECHO                                                     $12
         32        ECHO                                                     '+bytes%0A'
   29    33      > RETURN                                                   1

Function write_data:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0Qnh4
function name:  write_data
number of ops:  18
compiled vars:  !0 = $data, !1 = $outfp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
   25     1        INIT_FCALL                                               'fopen'
          2        SEND_VAL                                                 '%2Fdev%2Fnull'
          3        SEND_VAL                                                 'w'
          4        DO_ICALL                                         $2      
          5        ASSIGN                                                   !1, $2
   26     6        INIT_FCALL                                               'fwrite'
          7        SEND_VAR                                                 !1
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                                 
   27    10        INIT_FCALL                                               'fwrite'
         11        SEND_VAR                                                 !1
         12        SEND_VAL                                                 '%0A'
         13        DO_ICALL                                                 
   28    14        INIT_FCALL                                               'fclose'
         15        SEND_VAR                                                 !1
         16        DO_ICALL                                                 
   29    17      > RETURN                                                   null

End of function write_data

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.11 ms | 1400 KiB | 25 Q