3v4l.org

run code in 300+ PHP versions simultaneously
<?php function fpc($filename, $data) { // open file pointer, init flock options $fp = fopen($filename, 'w'); $retries = 0; $max_retries = 100; if (!$fp) { return false; } // loop until get lock, or reach max retries do { if ($retries > 0) { usleep(rand(1, 5000)); } $retries += 1; } while (!flock($fp, LOCK_EX) && $retries <= $max_retries); // couldn't get the lock if ($retries == $max_retries) { return false; } // got lock, write data fwrite($fp, $data); // release lock flock($fp, LOCK_UN); fclose($fp); return true; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ttaXh
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E > > RETURN                                                   1

Function fpc:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 12
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 21
Branch analysis from position: 14
2 jumps found. (Code = 46) Position 1 = 28, Position 2 = 30
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 12
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 34
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
Branch analysis from position: 30
Branch analysis from position: 21
filename:       /in/ttaXh
function name:  fpc
number of ops:  47
compiled vars:  !0 = $filename, !1 = $data, !2 = $fp, !3 = $retries, !4 = $max_retries
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        INIT_FCALL                                               'fopen'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 'w'
          5        DO_ICALL                                         $5      
          6        ASSIGN                                                   !2, $5
    5     7        ASSIGN                                                   !3, 0
    6     8        ASSIGN                                                   !4, 100
    8     9        BOOL_NOT                                         ~9      !2
         10      > JMPZ                                                     ~9, ->12
    9    11    > > RETURN                                                   <false>
   14    12    >   IS_SMALLER                                               0, !3
         13      > JMPZ                                                     ~10, ->21
   15    14    >   INIT_FCALL                                               'usleep'
         15        INIT_FCALL                                               'rand'
         16        SEND_VAL                                                 1
         17        SEND_VAL                                                 5000
         18        DO_ICALL                                         $11     
         19        SEND_VAR                                                 $11
         20        DO_ICALL                                                 
   17    21    >   ASSIGN_OP                                     1          !3, 1
   18    22        INIT_FCALL                                               'flock'
         23        SEND_VAR                                                 !2
         24        SEND_VAL                                                 2
         25        DO_ICALL                                         $14     
         26        BOOL_NOT                                         ~15     $14
         27      > JMPZ_EX                                          ~15     ~15, ->30
         28    >   IS_SMALLER_OR_EQUAL                              ~16     !3, !4
         29        BOOL                                             ~15     ~16
         30    > > JMPNZ                                                    ~15, ->12
   21    31    >   IS_EQUAL                                                 !3, !4
         32      > JMPZ                                                     ~17, ->34
   22    33    > > RETURN                                                   <false>
   26    34    >   INIT_FCALL                                               'fwrite'
         35        SEND_VAR                                                 !2
         36        SEND_VAR                                                 !1
         37        DO_ICALL                                                 
   29    38        INIT_FCALL                                               'flock'
         39        SEND_VAR                                                 !2
         40        SEND_VAL                                                 3
         41        DO_ICALL                                                 
   30    42        INIT_FCALL                                               'fclose'
         43        SEND_VAR                                                 !2
         44        DO_ICALL                                                 
   32    45      > RETURN                                                   <true>
   33    46*     > RETURN                                                   null

End of function fpc

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.85 ms | 1015 KiB | 19 Q