3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php // Get 10mb of data from /dev/zero try { $infp = fopen('/dev/zero', 'r'); $data = fread($infp, 1024 * 1024 * 10); } 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
Jump found. (Code = 162) Position 1 = 12, Position 2 = 11
Branch analysis from position: 12
Jump found. (Code = 46) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
Jump found. (Code = 43) Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
Jump found. (Code = 163) Position 1 = -2
Branch analysis from position: 21
Branch analysis from position: 16
Branch analysis from position: 11
Jump found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Jump found. (Code = 62) Position 1 = -2
filename:       /in/pR5Zp
function name:  (null)
number of ops:  35
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                                                 10485760
         8        DO_ICALL                                         $5      
         9        ASSIGN                                                   !1, $5
  10    10      > FAST_CALL                                                ->12
        11    > > JMP                                                      ->22
  11    12    >   ISSET_ISEMPTY_VAR                           310378496  ~7      !0
        13      > JMPZ_EX                                          ~7      ~7, ->16
        14    >   IS_NOT_IDENTICAL                                 ~8      !0, <false>
        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'
  23    33        NOP                                                      
  29    34      > RETURN                                                   1

Function write_data:
Finding entry points
Branch analysis from position: 0
Jump found. (Code = 62) Position 1 = -2
filename:       /in/pR5Zp
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 7.2.0