3v4l.org

run code in 500+ PHP versions simultaneously
<?php $urls = [ 'https://example.com/api/', 'https://www.example.com/test-subpath', 'https://www.example.com', 'example.com/test/page', 'www.example.com', 'www.subdomain.example.com', 'https://www.subdomain.example.com', 'subdomain.example.com', 'http://subdomain.example.com', 'https://subdomain.example.com', ]; function checkUrl(string $url): bool { return (bool)filter_var($url, FILTER_VALIDATE_URL); } foreach ($urls as $url) { if (checkUrl($url)) { echo $url . ' is a valid URL' . PHP_EOL; continue; } $urlWithProtocol = 'https://' . $url; if (checkUrl($urlWithProtocol)) { echo $urlWithProtocol . ' with added protocol is a valid URL' . PHP_EOL; continue; } echo $url . ' is not a valid URL' . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 25
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 25
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/oX2as
function name:  (null)
number of ops:  27
compiled vars:  !0 = $urls, !1 = $url, !2 = $urlWithProtocol
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   21     1      > FE_RESET_R                                           $4      !0, ->25
          2    > > FE_FETCH_R                                                   $4, !1, ->25
   22     3    >   INIT_FCALL                                                   'checkurl'
          4        SEND_VAR                                                     !1
          5        DO_FCALL                                          0  $5      
          6      > JMPZ                                                         $5, ->11
   23     7    >   CONCAT                                               ~6      !1, '+is+a+valid+URL'
          8        CONCAT                                               ~7      ~6, '%0A'
          9        ECHO                                                         ~7
   24    10      > JMP                                                          ->2
   27    11    >   CONCAT                                               ~8      'https%3A%2F%2F', !1
         12        ASSIGN                                                       !2, ~8
   28    13        INIT_FCALL                                                   'checkurl'
         14        SEND_VAR                                                     !2
         15        DO_FCALL                                          0  $10     
         16      > JMPZ                                                         $10, ->21
   29    17    >   CONCAT                                               ~11     !2, '+with+added+protocol+is+a+valid+URL'
         18        CONCAT                                               ~12     ~11, '%0A'
         19        ECHO                                                         ~12
   30    20      > JMP                                                          ->2
   33    21    >   CONCAT                                               ~13     !1, '+is+not+a+valid+URL'
         22        CONCAT                                               ~14     ~13, '%0A'
         23        ECHO                                                         ~14
   21    24      > JMP                                                          ->2
         25    >   FE_FREE                                                      $4
   34    26      > RETURN                                                       1

Function checkurl:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oX2as
function name:  checkUrl
number of ops:  10
compiled vars:  !0 = $url
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   16     0  E >   RECV                                                 !0      
   18     1        INIT_FCALL                                                   'filter_var'
          2        SEND_VAR                                                     !0
          3        SEND_VAL                                                     273
          4        DO_ICALL                                             $1      
          5        BOOL                                                 ~2      $1
          6        VERIFY_RETURN_TYPE                                           ~2
          7      > RETURN                                                       ~2
   19     8*       VERIFY_RETURN_TYPE                                           
          9*     > RETURN                                                       null

End of function checkurl

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
158.69 ms | 1663 KiB | 16 Q