3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = array('foo'=>'bar', 'baz'=>'boom', 'cow'=>'milk', 'php'=>'hypertext processor'); echo uri_appendQuery('http://domena/cesta/subor?query-string', $data), PHP_EOL; echo uri_appendQuery('http://domena/cesta/?query-string', $data), PHP_EOL; echo uri_appendQuery('http://domena/cesta/subor?', $data), PHP_EOL; echo uri_appendQuery('http://domena/cesta/subor', $data), PHP_EOL; echo uri_appendQuery('http://domena/cesta/subor?query-string', $data, TRUE), PHP_EOL; /** * Doplní k URL adrese zadané parametre za otáznikom. * * @param string URL adresa * @param array [názov parametru => hodnota] * @param bool ak je TRUE, nahradia sa všetky & v adrese za &amp; * @return string patrične upravenú URL adresu */ function uri_appendQuery($uri, array $args, $html = FALSE) { if(!$args) { // $args môže byť prázdne pole return $uri; } $sep= $html ? '&amp;' : '&'; if(FALSE === $qmpos = strpos($uri, '?')) { // adresa ešte neobsahuje query string $uri .= '?'; } elseif(strlen($uri) !== ($qmpos + 1)) { // adresa už obsahuje query string $uri .= $sep; } return $uri . http_build_query($args, NULL, $sep); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Srngt
function name:  (null)
number of ops:  33
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    8     1        INIT_FCALL_BY_NAME                                       'uri_appendQuery'
          2        SEND_VAL_EX                                              'http%3A%2F%2Fdomena%2Fcesta%2Fsubor%3Fquery-string'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $2      
          5        ECHO                                                     $2
          6        ECHO                                                     '%0A'
    9     7        INIT_FCALL_BY_NAME                                       'uri_appendQuery'
          8        SEND_VAL_EX                                              'http%3A%2F%2Fdomena%2Fcesta%2F%3Fquery-string'
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0  $3      
         11        ECHO                                                     $3
         12        ECHO                                                     '%0A'
   10    13        INIT_FCALL_BY_NAME                                       'uri_appendQuery'
         14        SEND_VAL_EX                                              'http%3A%2F%2Fdomena%2Fcesta%2Fsubor%3F'
         15        SEND_VAR_EX                                              !0
         16        DO_FCALL                                      0  $4      
         17        ECHO                                                     $4
         18        ECHO                                                     '%0A'
   11    19        INIT_FCALL_BY_NAME                                       'uri_appendQuery'
         20        SEND_VAL_EX                                              'http%3A%2F%2Fdomena%2Fcesta%2Fsubor'
         21        SEND_VAR_EX                                              !0
         22        DO_FCALL                                      0  $5      
         23        ECHO                                                     $5
         24        ECHO                                                     '%0A'
   12    25        INIT_FCALL_BY_NAME                                       'uri_appendQuery'
         26        SEND_VAL_EX                                              'http%3A%2F%2Fdomena%2Fcesta%2Fsubor%3Fquery-string'
         27        SEND_VAR_EX                                              !0
         28        SEND_VAL_EX                                              <true>
         29        DO_FCALL                                      0  $6      
         30        ECHO                                                     $6
         31        ECHO                                                     '%0A'
   37    32      > RETURN                                                   1

Function uri_appendquery:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 25
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
Branch analysis from position: 20
filename:       /in/Srngt
function name:  uri_appendQuery
number of ops:  33
compiled vars:  !0 = $uri, !1 = $args, !2 = $html, !3 = $sep, !4 = $qmpos
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      <false>
   23     3        BOOL_NOT                                         ~5      !1
          4      > JMPZ                                                     ~5, ->6
   24     5    > > RETURN                                                   !0
   27     6    > > JMPZ                                                     !2, ->9
          7    >   QM_ASSIGN                                        ~6      '%26amp%3B'
          8      > JMP                                                      ->10
          9    >   QM_ASSIGN                                        ~6      '%26'
         10    >   ASSIGN                                                   !3, ~6
   29    11        INIT_FCALL                                               'strpos'
         12        SEND_VAR                                                 !0
         13        SEND_VAL                                                 '%3F'
         14        DO_ICALL                                         $8      
         15        ASSIGN                                           ~9      !4, $8
         16        TYPE_CHECK                                    4          ~9
         17      > JMPZ                                                     ~10, ->20
   30    18    >   ASSIGN_OP                                     8          !0, '%3F'
         19      > JMP                                                      ->25
   31    20    >   STRLEN                                           ~12     !0
         21        ADD                                              ~13     !4, 1
         22        IS_NOT_IDENTICAL                                         ~12, ~13
         23      > JMPZ                                                     ~14, ->25
   32    24    >   ASSIGN_OP                                     8          !0, !3
   36    25    >   INIT_FCALL                                               'http_build_query'
         26        SEND_VAR                                                 !1
         27        SEND_VAL                                                 null
         28        SEND_VAR                                                 !3
         29        DO_ICALL                                         $16     
         30        CONCAT                                           ~17     !0, $16
         31      > RETURN                                                   ~17
   37    32*     > RETURN                                                   null

End of function uri_appendquery

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
126.89 ms | 1405 KiB | 17 Q