3v4l.org

run code in 300+ PHP versions simultaneously
<?php function build_external_url(string $host, string $path = null, array $query = [], string $schema = null, int $port = null): string { $url = $host; if (null !== $port) { $url .= ':' . $port; } if (null !== $path) { $url .= '/' . ltrim($path, '/'); } if (! empty($query)) { $url .= '?' . http_build_query($query); } return (null === $schema ? $url : ($schema . '://' . $url)); } $tests = [ [ 'foo.co' ], [ 'foo.co', '/bar' ], [ 'foo.co', 'bar', [ 'x' => 'baz' ]], [ 'foo.co', 'bar', [], 'ftp' ], [ 'foo.co', 'bar', ['email' => 'me@foo.co'], 'ftp', '24225'], ]; foreach ($tests as $args) { echo build_external_url(...$args) . PHP_EOL; }
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/IT2fo
function name:  (null)
number of ops:  12
compiled vars:  !0 = $tests, !1 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   ASSIGN                                                   !0, <array>
   25     1      > FE_RESET_R                                       $3      !0, ->10
          2    > > FE_FETCH_R                                               $3, !1, ->10
   26     3    >   INIT_FCALL                                               'build_external_url'
          4        SEND_UNPACK                                              !1
          5        CHECK_UNDEF_ARGS                                         
          6        DO_FCALL                                      1  $4      
          7        CONCAT                                           ~5      $4, '%0A'
          8        ECHO                                                     ~5
   25     9      > JMP                                                      ->2
         10    >   FE_FREE                                                  $3
   27    11      > RETURN                                                   1

Function build_external_url:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 18
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 26
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 30
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
Branch analysis from position: 18
Branch analysis from position: 10
filename:       /in/IT2fo
function name:  build_external_url
number of ops:  37
compiled vars:  !0 = $host, !1 = $path, !2 = $query, !3 = $schema, !4 = $port, !5 = $url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
          2        RECV_INIT                                        !2      <array>
          3        RECV_INIT                                        !3      null
          4        RECV_INIT                                        !4      null
    5     5        ASSIGN                                                   !5, !0
    6     6        TYPE_CHECK                                  1020          !4
          7      > JMPZ                                                     ~7, ->10
    7     8    >   CONCAT                                           ~8      '%3A', !4
          9        ASSIGN_OP                                     8          !5, ~8
    9    10    >   TYPE_CHECK                                  1020          !1
         11      > JMPZ                                                     ~10, ->18
   10    12    >   INIT_FCALL                                               'ltrim'
         13        SEND_VAR                                                 !1
         14        SEND_VAL                                                 '%2F'
         15        DO_ICALL                                         $11     
         16        CONCAT                                           ~12     '%2F', $11
         17        ASSIGN_OP                                     8          !5, ~12
   12    18    >   ISSET_ISEMPTY_CV                                 ~14     !2
         19        BOOL_NOT                                         ~15     ~14
         20      > JMPZ                                                     ~15, ->26
   13    21    >   INIT_FCALL                                               'http_build_query'
         22        SEND_VAR                                                 !2
         23        DO_ICALL                                         $16     
         24        CONCAT                                           ~17     '%3F', $16
         25        ASSIGN_OP                                     8          !5, ~17
   15    26    >   TYPE_CHECK                                    2          !3
         27      > JMPZ                                                     ~19, ->30
         28    >   QM_ASSIGN                                        ~20     !5
         29      > JMP                                                      ->33
         30    >   CONCAT                                           ~21     !3, '%3A%2F%2F'
         31        CONCAT                                           ~22     ~21, !5
         32        QM_ASSIGN                                        ~20     ~22
         33    >   VERIFY_RETURN_TYPE                                       ~20
         34      > RETURN                                                   ~20
   16    35*       VERIFY_RETURN_TYPE                                       
         36*     > RETURN                                                   null

End of function build_external_url

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.99 ms | 1006 KiB | 16 Q