3v4l.org

run code in 300+ PHP versions simultaneously
<?php function urlWhitelisted($url) { $always_allowed = array('localhost'); $whitelisted_domains = array('fxnetworks.com') + $always_allowed; $domain = parse_url($url); var_dump($domain); if (strpos($url, "/") === 0 || in_array($domain, $whitelisted_domains)) { return true; } foreach ($whitelisted_domains as $whitelisted_domain) { $whitelisted_domain = '.' . $whitelisted_domain; if (strpos($domain, $whitelisted_domain) === (strlen($domain) - strlen($whitelisted_domain))) { return true; } } return false; } $domains = array('/user', 'localhost/user', 'http://localhost:4039', 'http://fxnetworks.com/user', 'http://google.com', 'google.com', 'fxnetworks.com.google.com'); foreach($domains as $domain) { var_dump(urlWhitelisted($domain)); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 10
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 10
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/H2pNe
function name:  (null)
number of ops:  12
compiled vars:  !0 = $domains, !1 = $domain
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   ASSIGN                                                   !0, <array>
   27     1      > FE_RESET_R                                       $3      !0, ->10
          2    > > FE_FETCH_R                                               $3, !1, ->10
   28     3    >   INIT_FCALL                                               'var_dump'
          4        INIT_FCALL                                               'urlwhitelisted'
          5        SEND_VAR                                                 !1
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
   27     9      > JMP                                                      ->2
         10    >   FE_FREE                                                  $3
   29    11      > RETURN                                                   1

Function urlwhitelisted:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 17, Position 2 = 22
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 24
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
2 jumps found. (Code = 77) Position 1 = 25, Position 2 = 40
Branch analysis from position: 25
2 jumps found. (Code = 78) Position 1 = 26, Position 2 = 40
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 39
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
Branch analysis from position: 22
filename:       /in/H2pNe
function name:  urlWhitelisted
number of ops:  43
compiled vars:  !0 = $url, !1 = $always_allowed, !2 = $whitelisted_domains, !3 = $domain, !4 = $whitelisted_domain
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, <array>
    6     2        ADD                                              ~6      <array>, !1
          3        ASSIGN                                                   !2, ~6
    8     4        INIT_FCALL                                               'parse_url'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $8      
          7        ASSIGN                                                   !3, $8
    9     8        INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !3
         10        DO_ICALL                                                 
   11    11        INIT_FCALL                                               'strpos'
         12        SEND_VAR                                                 !0
         13        SEND_VAL                                                 '%2F'
         14        DO_ICALL                                         $11     
         15        IS_IDENTICAL                                     ~12     $11, 0
         16      > JMPNZ_EX                                         ~12     ~12, ->22
         17    >   INIT_FCALL                                               'in_array'
         18        SEND_VAR                                                 !3
         19        SEND_VAR                                                 !2
         20        DO_ICALL                                         $13     
         21        BOOL                                             ~12     $13
         22    > > JMPZ                                                     ~12, ->24
   12    23    > > RETURN                                                   <true>
   15    24    > > FE_RESET_R                                       $14     !2, ->40
         25    > > FE_FETCH_R                                               $14, !4, ->40
   16    26    >   CONCAT                                           ~15     '.', !4
         27        ASSIGN                                                   !4, ~15
   17    28        INIT_FCALL                                               'strpos'
         29        SEND_VAR                                                 !3
         30        SEND_VAR                                                 !4
         31        DO_ICALL                                         $17     
         32        STRLEN                                           ~18     !3
         33        STRLEN                                           ~19     !4
         34        SUB                                              ~20     ~18, ~19
         35        IS_IDENTICAL                                             $17, ~20
         36      > JMPZ                                                     ~21, ->39
   18    37    >   FE_FREE                                                  $14
         38      > RETURN                                                   <true>
   15    39    > > JMP                                                      ->25
         40    >   FE_FREE                                                  $14
   22    41      > RETURN                                                   <false>
   23    42*     > RETURN                                                   null

End of function urlwhitelisted

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.86 ms | 1403 KiB | 22 Q