3v4l.org

run code in 300+ PHP versions simultaneously
<?php function addSchema($url, $shemaToAdd = 'http') { $allowedShemas = array('http', 'https'); if(!in_array($shemaToAdd, $allowedShemas)) { throw new Exception('Shema is not allowed: ' .$shemaToAdd); } foreach($allowedShemas as $shema) { $shema.= '://'; if(substr($url, 0, strlen($shema)) === $shema) { $url = substr($url, 0, strlen($shema)); break; } } return $shemaToAdd . '://' . $url; } $url = ' http://exkavator.ru/trade/parts/message/7113.html'; echo addSchema($url);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1ErUr
function name:  (null)
number of ops:  6
compiled vars:  !0 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   ASSIGN                                                   !0, '+http%3A%2F%2Fexkavator.ru%2Ftrade%2Fparts%2Fmessage%2F7113.html'
   27     1        INIT_FCALL                                               'addschema'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $2      
          4        ECHO                                                     $2
          5      > RETURN                                                   1

Function addschema:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 14
Branch analysis from position: 9
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 34
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 34
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 33
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 34
Branch analysis from position: 34
filename:       /in/1ErUr
function name:  addSchema
number of ops:  39
compiled vars:  !0 = $url, !1 = $shemaToAdd, !2 = $allowedShemas, !3 = $shema
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      'http'
    5     2        ASSIGN                                                   !2, <array>
    7     3        INIT_FCALL                                               'in_array'
          4        SEND_VAR                                                 !1
          5        SEND_VAR                                                 !2
          6        DO_ICALL                                         $5      
          7        BOOL_NOT                                         ~6      $5
          8      > JMPZ                                                     ~6, ->14
    8     9    >   NEW                                              $7      'Exception'
         10        CONCAT                                           ~8      'Shema+is+not+allowed%3A+', !1
         11        SEND_VAL_EX                                              ~8
         12        DO_FCALL                                      0          
         13      > THROW                                         0          $7
   11    14    > > FE_RESET_R                                       $10     !2, ->34
         15    > > FE_FETCH_R                                               $10, !3, ->34
   13    16    >   ASSIGN_OP                                     8          !3, '%3A%2F%2F'
   14    17        INIT_FCALL                                               'substr'
         18        SEND_VAR                                                 !0
         19        SEND_VAL                                                 0
         20        STRLEN                                           ~12     !3
         21        SEND_VAL                                                 ~12
         22        DO_ICALL                                         $13     
         23        IS_IDENTICAL                                             !3, $13
         24      > JMPZ                                                     ~14, ->33
   16    25    >   INIT_FCALL                                               'substr'
         26        SEND_VAR                                                 !0
         27        SEND_VAL                                                 0
         28        STRLEN                                           ~15     !3
         29        SEND_VAL                                                 ~15
         30        DO_ICALL                                         $16     
         31        ASSIGN                                                   !0, $16
   17    32      > JMP                                                      ->34
   11    33    > > JMP                                                      ->15
         34    >   FE_FREE                                                  $10
   21    35        CONCAT                                           ~18     !1, '%3A%2F%2F'
         36        CONCAT                                           ~19     ~18, !0
         37      > RETURN                                                   ~19
   22    38*     > RETURN                                                   null

End of function addschema

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.73 ms | 1403 KiB | 18 Q