3v4l.org

run code in 300+ PHP versions simultaneously
<?php $base = '/some/dir'; $path = '/foo/bar'; $protect = array('/bar','/foo','/bob'); foreach($protect as $needle) { echo "Checking for needle $needle in path $path:\n"; $sp = strpos($path,$needle); echo "Strpos result: $sp\n"; if( $sp !==FALSE ) { echo "Path contains the needle\n"; $s=strcmp( $needle, $path ); echo "Strcmp result: $s\n"; if( $s > 0 ) { echo "The path is a subfolder inside the needle"; } else { echo "The path isn't a subfolder inside the needle"; } } else { echo "The path doesn't contain the needle"; } echo "\n\n"; } echo "Check completed"; ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 41
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 41
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 38
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 36
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
filename:       /in/rX7lD
function name:  (null)
number of ops:  44
compiled vars:  !0 = $base, !1 = $path, !2 = $protect, !3 = $needle, !4 = $sp, !5 = $s
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%2Fsome%2Fdir'
    4     1        ASSIGN                                                   !1, '%2Ffoo%2Fbar'
    5     2        ASSIGN                                                   !2, <array>
    7     3      > FE_RESET_R                                       $9      !2, ->41
          4    > > FE_FETCH_R                                               $9, !3, ->41
    8     5    >   ROPE_INIT                                     5  ~11     'Checking+for+needle+'
          6        ROPE_ADD                                      1  ~11     ~11, !3
          7        ROPE_ADD                                      2  ~11     ~11, '+in+path+'
          8        ROPE_ADD                                      3  ~11     ~11, !1
          9        ROPE_END                                      4  ~10     ~11, '%3A%0A'
         10        ECHO                                                     ~10
    9    11        INIT_FCALL                                               'strpos'
         12        SEND_VAR                                                 !1
         13        SEND_VAR                                                 !3
         14        DO_ICALL                                         $14     
         15        ASSIGN                                                   !4, $14
   10    16        ROPE_INIT                                     3  ~17     'Strpos+result%3A+'
         17        ROPE_ADD                                      1  ~17     ~17, !4
         18        ROPE_END                                      2  ~16     ~17, '%0A'
         19        ECHO                                                     ~16
   11    20        TYPE_CHECK                                  1018          !4
         21      > JMPZ                                                     ~19, ->38
   12    22    >   ECHO                                                     'Path+contains+the+needle%0A'
   13    23        INIT_FCALL                                               'strcmp'
         24        SEND_VAR                                                 !3
         25        SEND_VAR                                                 !1
         26        DO_ICALL                                         $20     
         27        ASSIGN                                                   !5, $20
   14    28        ROPE_INIT                                     3  ~23     'Strcmp+result%3A+'
         29        ROPE_ADD                                      1  ~23     ~23, !5
         30        ROPE_END                                      2  ~22     ~23, '%0A'
         31        ECHO                                                     ~22
   15    32        IS_SMALLER                                               0, !5
         33      > JMPZ                                                     ~25, ->36
   16    34    >   ECHO                                                     'The+path+is+a+subfolder+inside+the+needle'
         35      > JMP                                                      ->37
   18    36    >   ECHO                                                     'The+path+isn%27t+a+subfolder+inside+the+needle'
         37    > > JMP                                                      ->39
   21    38    >   ECHO                                                     'The+path+doesn%27t+contain+the+needle'
   23    39    >   ECHO                                                     '%0A%0A'
    7    40      > JMP                                                      ->4
         41    >   FE_FREE                                                  $9
   25    42        ECHO                                                     'Check+completed'
   26    43      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
193.14 ms | 1400 KiB | 17 Q