3v4l.org

run code in 300+ PHP versions simultaneously
<?php $links = array( 'test.com', 'http://test.net', 'https://secure.net', 'www.test.net', 'spotify:csad456ds4a6d', 'hey', 'hey.net', 'mailto:victor.loux@mtcmedia.co.uk', '192.168.0.1', 'ftp://test@mtcmedia.co.uk' ); foreach($links as $link) { $link = addhttp($link); echo $link . PHP_EOL; } function addhttp($url) { if (!preg_match("~^(?:f|ht)tps?://~i", $url)) { $url = "http://" . $url; } return $url; }
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/p3oYR
function name:  (null)
number of ops:  12
compiled vars:  !0 = $links, !1 = $link
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   15     1      > FE_RESET_R                                       $3      !0, ->10
          2    > > FE_FETCH_R                                               $3, !1, ->10
   16     3    >   INIT_FCALL_BY_NAME                                       'addhttp'
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0  $4      
          6        ASSIGN                                                   !1, $4
   18     7        CONCAT                                           ~6      !1, '%0A'
          8        ECHO                                                     ~6
   15     9      > JMP                                                      ->2
         10    >   FE_FREE                                                  $3
   26    11      > RETURN                                                   1

Function addhttp:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/p3oYR
function name:  addhttp
number of ops:  11
compiled vars:  !0 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   22     1        INIT_FCALL                                               'preg_match'
          2        SEND_VAL                                                 '%7E%5E%28%3F%3Af%7Cht%29tps%3F%3A%2F%2F%7Ei'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $1      
          5        BOOL_NOT                                         ~2      $1
          6      > JMPZ                                                     ~2, ->9
   23     7    >   CONCAT                                           ~3      'http%3A%2F%2F', !0
          8        ASSIGN                                                   !0, ~3
   25     9    > > RETURN                                                   !0
   26    10*     > RETURN                                                   null

End of function addhttp

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.83 ms | 1396 KiB | 15 Q