3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function makeRandomPath($dir, $ext) { do { $path = $dir."/".genRandomString().".".$ext; } while(file_exists($path)); return $path; } echo makeRandomPath(); function makeRandomPathFromFilename($dir, $fn) { $ext = pathinfo($fn, PATHINFO_EXTENSION); return makeRandomPath($dir, $ext); } echo makeRandomPathFromFilename();
based on XsZ3D
Finding entry points
Branch analysis from position: 0
Jump found. (Code = 62) Position 1 = -2
filename:       /in/uJBv6
function name:  (null)
number of ops:  9
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   NOP                                                      
   9     1        INIT_FCALL                                               'makerandompath'
         2        DO_FCALL                                      0  $0      
         3        ECHO                                                     $0
  11     4        NOP                                                      
  15     5        INIT_FCALL                                               'makerandompathfromfilename'
         6        DO_FCALL                                      0  $1      
         7        ECHO                                                     $1
         8      > RETURN                                                   1

Function makerandompath:
Finding entry points
Branch analysis from position: 0
Jump found. (Code = 44) Position 1 = 13, Position 2 = 2
Branch analysis from position: 13
Jump found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
filename:       /in/uJBv6
function name:  makeRandomPath
number of ops:  15
compiled vars:  !0 = $dir, !1 = $ext, !2 = $path
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   RECV                                             !0      
         1        RECV                                             !1      
   5     2    >   CONCAT                                           ~3      !0, '%2F'
         3        INIT_FCALL_BY_NAME                                       'genRandomString'
         4        DO_FCALL                                      0  $4      
         5        CONCAT                                           ~5      ~3, $4
         6        CONCAT                                           ~6      ~5, '.'
         7        CONCAT                                           ~7      ~6, !1
         8        ASSIGN                                                   !2, ~7
   6     9        INIT_FCALL                                               'file_exists'
        10        SEND_VAR                                                 !2
        11        DO_ICALL                                         $9      
        12      > JMPNZ                                                    $9, ->2
   7    13    > > RETURN                                                   !2
   8    14*     > RETURN                                                   null

End of function makerandompath

Function makerandompathfromfilename:
Finding entry points
Branch analysis from position: 0
Jump found. (Code = 62) Position 1 = -2
filename:       /in/uJBv6
function name:  makeRandomPathFromFilename
number of ops:  13
compiled vars:  !0 = $dir, !1 = $fn, !2 = $ext
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  11     0  E >   RECV                                             !0      
         1        RECV                                             !1      
  12     2        INIT_FCALL                                               'pathinfo'
         3        SEND_VAR                                                 !1
         4        SEND_VAL                                                 4
         5        DO_ICALL                                         $3      
         6        ASSIGN                                                   !2, $3
  13     7        INIT_FCALL                                               'makerandompath'
         8        SEND_VAR                                                 !0
         9        SEND_VAR                                                 !2
        10        DO_FCALL                                      0  $5      
        11      > RETURN                                                   $5
  14    12*     > RETURN                                                   null

End of function makerandompathfromfilename

Generated using Vulcan Logic Dumper, using php 7.2.0