3v4l.org

run code in 300+ PHP versions simultaneously
<?php $replacer = function ($scheme, $url) { return preg_replace('/^https?/', $scheme, $url); }; $originals = [ 'http://fake.url', 'https://fake.url/ssl', ]; $schemes = ['http', 'https']; foreach ($schemes as $iteration => $scheme) { foreach ($originals as $urlToReplace) { echo "\n#$iteration"; echo "\nScheme: $scheme"; echo "\nOriginal URL: $urlToReplace"; $newUrl = replacer($scheme, $urlToReplace); echo "\New URL: $newUrl"; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 29
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 29
Branch analysis from position: 6
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 27
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 27
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 27
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/IKSbM
function name:  (null)
number of ops:  31
compiled vars:  !0 = $replacer, !1 = $originals, !2 = $schemes, !3 = $scheme, !4 = $iteration, !5 = $urlToReplace, !6 = $newUrl
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FIKSbM%3A2%240'
          1        ASSIGN                                                   !0, ~7
    6     2        ASSIGN                                                   !1, <array>
   11     3        ASSIGN                                                   !2, <array>
   13     4      > FE_RESET_R                                       $11     !2, ->29
          5    > > FE_FETCH_R                                       ~12     $11, !3, ->29
          6    >   ASSIGN                                                   !4, ~12
   14     7      > FE_RESET_R                                       $14     !1, ->27
          8    > > FE_FETCH_R                                               $14, !5, ->27
   15     9    >   NOP                                                      
         10        FAST_CONCAT                                      ~15     '%0A%23', !4
         11        ECHO                                                     ~15
   16    12        NOP                                                      
         13        FAST_CONCAT                                      ~16     '%0AScheme%3A+', !3
         14        ECHO                                                     ~16
   17    15        NOP                                                      
         16        FAST_CONCAT                                      ~17     '%0AOriginal+URL%3A+', !5
         17        ECHO                                                     ~17
   18    18        INIT_FCALL_BY_NAME                                       'replacer'
         19        SEND_VAR_EX                                              !3
         20        SEND_VAR_EX                                              !5
         21        DO_FCALL                                      0  $18     
         22        ASSIGN                                                   !6, $18
   19    23        NOP                                                      
         24        FAST_CONCAT                                      ~20     '%5CNew+URL%3A+', !6
         25        ECHO                                                     ~20
   14    26      > JMP                                                      ->8
         27    >   FE_FREE                                                  $14
   13    28      > JMP                                                      ->5
         29    >   FE_FREE                                                  $11
   21    30      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FIKSbM%3A2%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IKSbM
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $scheme, !1 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2        INIT_FCALL                                               'preg_replace'
          3        SEND_VAL                                                 '%2F%5Ehttps%3F%2F'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $2      
          7      > RETURN                                                   $2
    4     8*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FIKSbM%3A2%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
181.72 ms | 1400 KiB | 15 Q