3v4l.org

run code in 300+ PHP versions simultaneously
<?php $_GET['sortBy'] = 'B'; function get_permalink() { return 'someurl'; } function get_terms($array) { return ['foo', 'bar', 'öle', 'can']; } function esc_html($string) { return htmlspecialchars($string, ENT_QUOTES); } function alpha_pagination() { $chars = array_fill_keys(range('A', 'Z'), false); foreach (get_terms(['taxonomy' => 'unknown', 'hide_empty' => true]) as $tax) { $chars[mb_strtoupper(mb_substr($tax, 0, 1))] = true; } ksort($chars); foreach ($chars as $char => $hasTerms) { $selected = ($_GET['sortBy'] ?? '_') === $char ? ' selected' : ''; if ($hasTerms) { printf( '<a class="button%s" href="%s?%s">%s</a>', $selected, get_permalink(), http_build_query(['sortby' => $char]), esc_html($char) ); } else { printf( '<span class="button disabled%s">%s</span>', $selected, esc_html($char) ); } echo "\n"; } } alpha_pagination();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VbFGY
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   FETCH_W                      global              $0      '_GET'
          1        ASSIGN_DIM                                               $0, 'sortBy'
          2        OP_DATA                                                  'B'
   40     3        INIT_FCALL                                               'alpha_pagination'
          4        DO_FCALL                                      0          
          5      > RETURN                                                   1

Function get_permalink:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VbFGY
function name:  get_permalink
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E > > RETURN                                                   'someurl'
          1*     > RETURN                                                   null

End of function get_permalink

Function get_terms:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VbFGY
function name:  get_terms
number of ops:  3
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1      > RETURN                                                   <array>
          2*     > RETURN                                                   null

End of function get_terms

Function esc_html:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VbFGY
function name:  esc_html
number of ops:  7
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'htmlspecialchars'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 3
          4        DO_ICALL                                         $1      
          5      > RETURN                                                   $1
          6*     > RETURN                                                   null

End of function esc_html

Function alpha_pagination:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 25
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 25
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 25
2 jumps found. (Code = 77) Position 1 = 30, Position 2 = 70
Branch analysis from position: 30
2 jumps found. (Code = 78) Position 1 = 31, Position 2 = 70
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 40
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 60
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 68
Branch analysis from position: 68
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 60
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 60
Branch analysis from position: 43
Branch analysis from position: 60
Branch analysis from position: 70
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 70
Branch analysis from position: 25
filename:       /in/VbFGY
function name:  alpha_pagination
number of ops:  72
compiled vars:  !0 = $chars, !1 = $tax, !2 = $hasTerms, !3 = $char, !4 = $selected
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_FCALL                                               'array_fill_keys'
          1        INIT_FCALL                                               'range'
          2        SEND_VAL                                                 'A'
          3        SEND_VAL                                                 'Z'
          4        DO_ICALL                                         $5      
          5        SEND_VAR                                                 $5
          6        SEND_VAL                                                 <false>
          7        DO_ICALL                                         $6      
          8        ASSIGN                                                   !0, $6
   14     9        INIT_FCALL                                               'get_terms'
         10        SEND_VAL                                                 <array>
         11        DO_FCALL                                      0  $8      
         12      > FE_RESET_R                                       $9      $8, ->25
         13    > > FE_FETCH_R                                               $9, !1, ->25
   15    14    >   INIT_FCALL                                               'mb_strtoupper'
         15        INIT_FCALL                                               'mb_substr'
         16        SEND_VAR                                                 !1
         17        SEND_VAL                                                 0
         18        SEND_VAL                                                 1
         19        DO_ICALL                                         $10     
         20        SEND_VAR                                                 $10
         21        DO_ICALL                                         $11     
         22        ASSIGN_DIM                                               !0, $11
         23        OP_DATA                                                  <true>
   14    24      > JMP                                                      ->13
         25    >   FE_FREE                                                  $9
   17    26        INIT_FCALL                                               'ksort'
         27        SEND_REF                                                 !0
         28        DO_ICALL                                                 
   19    29      > FE_RESET_R                                       $14     !0, ->70
         30    > > FE_FETCH_R                                       ~15     $14, !2, ->70
         31    >   ASSIGN                                                   !3, ~15
   20    32        FETCH_IS                                         ~17     '_GET'
         33        FETCH_DIM_IS                                     ~18     ~17, 'sortBy'
         34        COALESCE                                         ~19     ~18
         35        QM_ASSIGN                                        ~19     '_'
         36        IS_IDENTICAL                                             !3, ~19
         37      > JMPZ                                                     ~20, ->40
         38    >   QM_ASSIGN                                        ~21     '+selected'
         39      > JMP                                                      ->41
         40    >   QM_ASSIGN                                        ~21     ''
         41    >   ASSIGN                                                   !4, ~21
   21    42      > JMPZ                                                     !2, ->60
   22    43    >   INIT_FCALL                                               'printf'
   23    44        SEND_VAL                                                 '%3Ca+class%3D%22button%25s%22+href%3D%22%25s%3F%25s%22%3E%25s%3C%2Fa%3E'
   24    45        SEND_VAR                                                 !4
   25    46        INIT_FCALL                                               'get_permalink'
         47        DO_FCALL                                      0  $23     
         48        SEND_VAR                                                 $23
   26    49        INIT_FCALL                                               'http_build_query'
         50        INIT_ARRAY                                       ~24     !3, 'sortby'
         51        SEND_VAL                                                 ~24
         52        DO_ICALL                                         $25     
         53        SEND_VAR                                                 $25
   27    54        INIT_FCALL                                               'esc_html'
         55        SEND_VAR                                                 !3
         56        DO_FCALL                                      0  $26     
         57        SEND_VAR                                                 $26
         58        DO_ICALL                                                 
         59      > JMP                                                      ->68
   30    60    >   INIT_FCALL                                               'printf'
   31    61        SEND_VAL                                                 '%3Cspan+class%3D%22button+disabled%25s%22%3E%25s%3C%2Fspan%3E'
   32    62        SEND_VAR                                                 !4
   33    63        INIT_FCALL                                               'esc_html'
         64        SEND_VAR                                                 !3
         65        DO_FCALL                                      0  $28     
         66        SEND_VAR                                                 $28
         67        DO_ICALL                                                 
   36    68    >   ECHO                                                     '%0A'
   19    69      > JMP                                                      ->30
         70    >   FE_FREE                                                  $14
   38    71      > RETURN                                                   null

End of function alpha_pagination

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.15 ms | 1418 KiB | 34 Q