3v4l.org

run code in 300+ PHP versions simultaneously
<?php function generateTmpFilename(): string { $filename = sys_get_temp_dir().'/'.bin2hex(random_bytes(16)).'.tmp'; touch($filename); return $filename; } $tmpFilename = generateTmpFilename(); $f = fopen($tmpFilename, 'rwb'); # this is the only difference fwrite($f, 'Woop die loop'); fwrite($f, 'Scoop'); fclose($f); # Note that this is empty output var_dump(file_get_contents($tmpFilename)); $tmpFilename = generateTmpFilename(); $f = fopen($tmpFilename, 'wrb'); # this is the only difference fwrite($f, 'I ate'); fwrite($f, 'Noogie'); fclose($f); # And this one contains expected text var_dump(file_get_contents($tmpFilename));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/V6088
function name:  (null)
number of ops:  51
compiled vars:  !0 = $tmpFilename, !1 = $f
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INIT_FCALL                                               'generatetmpfilename'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   11     3        INIT_FCALL                                               'fopen'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 'rwb'
          6        DO_ICALL                                         $4      
          7        ASSIGN                                                   !1, $4
   13     8        INIT_FCALL                                               'fwrite'
          9        SEND_VAR                                                 !1
         10        SEND_VAL                                                 'Woop+die+loop'
         11        DO_ICALL                                                 
   14    12        INIT_FCALL                                               'fwrite'
         13        SEND_VAR                                                 !1
         14        SEND_VAL                                                 'Scoop'
         15        DO_ICALL                                                 
   15    16        INIT_FCALL                                               'fclose'
         17        SEND_VAR                                                 !1
         18        DO_ICALL                                                 
   18    19        INIT_FCALL                                               'var_dump'
         20        INIT_FCALL                                               'file_get_contents'
         21        SEND_VAR                                                 !0
         22        DO_ICALL                                         $9      
         23        SEND_VAR                                                 $9
         24        DO_ICALL                                                 
   20    25        INIT_FCALL                                               'generatetmpfilename'
         26        DO_FCALL                                      0  $11     
         27        ASSIGN                                                   !0, $11
   21    28        INIT_FCALL                                               'fopen'
         29        SEND_VAR                                                 !0
         30        SEND_VAL                                                 'wrb'
         31        DO_ICALL                                         $13     
         32        ASSIGN                                                   !1, $13
   23    33        INIT_FCALL                                               'fwrite'
         34        SEND_VAR                                                 !1
         35        SEND_VAL                                                 'I+ate'
         36        DO_ICALL                                                 
   24    37        INIT_FCALL                                               'fwrite'
         38        SEND_VAR                                                 !1
         39        SEND_VAL                                                 'Noogie'
         40        DO_ICALL                                                 
   25    41        INIT_FCALL                                               'fclose'
         42        SEND_VAR                                                 !1
         43        DO_ICALL                                                 
   28    44        INIT_FCALL                                               'var_dump'
         45        INIT_FCALL                                               'file_get_contents'
         46        SEND_VAR                                                 !0
         47        DO_ICALL                                         $18     
         48        SEND_VAR                                                 $18
         49        DO_ICALL                                                 
         50      > RETURN                                                   1

Function generatetmpfilename:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/V6088
function name:  generateTmpFilename
number of ops:  19
compiled vars:  !0 = $filename
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   INIT_FCALL                                               'sys_get_temp_dir'
          1        DO_ICALL                                         $1      
          2        CONCAT                                           ~2      $1, '%2F'
          3        INIT_FCALL                                               'bin2hex'
          4        INIT_FCALL                                               'random_bytes'
          5        SEND_VAL                                                 16
          6        DO_ICALL                                         $3      
          7        SEND_VAR                                                 $3
          8        DO_ICALL                                         $4      
          9        CONCAT                                           ~5      ~2, $4
         10        CONCAT                                           ~6      ~5, '.tmp'
         11        ASSIGN                                                   !0, ~6
    6    12        INIT_FCALL                                               'touch'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                                 
    7    15        VERIFY_RETURN_TYPE                                       !0
         16      > RETURN                                                   !0
    8    17*       VERIFY_RETURN_TYPE                                       
         18*     > RETURN                                                   null

End of function generatetmpfilename

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.07 ms | 1403 KiB | 33 Q