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) { printf( '<%1$s class="button%2$s%3$s">%4$s</%1$s>' . "\n", $hasTerms ? 'a' : 'span', // %1$s ($_GET['sortBy'] ?? '_') === $char ? ' selected' : '', // %2$s $hasTerms ? '" href="' . get_permalink() . '?' . http_build_query(['sortby' => $char]) : ' disable', // %3$s esc_html($char) // %4$s ); } } alpha_pagination();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JgHGY
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'
   30     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/JgHGY
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/JgHGY
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/JgHGY
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 = 69
Branch analysis from position: 30
2 jumps found. (Code = 78) Position 1 = 31, Position 2 = 69
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 37
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
2 jumps found. (Code = 43) Position 1 = 45, Position 2 = 47
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
2 jumps found. (Code = 43) Position 1 = 50, Position 2 = 61
Branch analysis from position: 50
1 jumps found. (Code = 42) Position 1 = 62
Branch analysis from position: 62
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 61
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 47
2 jumps found. (Code = 43) Position 1 = 50, Position 2 = 61
Branch analysis from position: 50
Branch analysis from position: 61
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 45, Position 2 = 47
Branch analysis from position: 45
Branch analysis from position: 47
Branch analysis from position: 69
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 69
Branch analysis from position: 25
filename:       /in/JgHGY
function name:  alpha_pagination
number of ops:  71
compiled vars:  !0 = $chars, !1 = $tax, !2 = $hasTerms, !3 = $char
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                                         $4      
          5        SEND_VAR                                                 $4
          6        SEND_VAL                                                 <false>
          7        DO_ICALL                                         $5      
          8        ASSIGN                                                   !0, $5
   14     9        INIT_FCALL                                               'get_terms'
         10        SEND_VAL                                                 <array>
         11        DO_FCALL                                      0  $7      
         12      > FE_RESET_R                                       $8      $7, ->25
         13    > > FE_FETCH_R                                               $8, !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                                         $9      
         20        SEND_VAR                                                 $9
         21        DO_ICALL                                         $10     
         22        ASSIGN_DIM                                               !0, $10
         23        OP_DATA                                                  <true>
   14    24      > JMP                                                      ->13
         25    >   FE_FREE                                                  $8
   17    26        INIT_FCALL                                               'ksort'
         27        SEND_REF                                                 !0
         28        DO_ICALL                                                 
   19    29      > FE_RESET_R                                       $13     !0, ->69
         30    > > FE_FETCH_R                                       ~14     $13, !2, ->69
         31    >   ASSIGN                                                   !3, ~14
   20    32        INIT_FCALL                                               'printf'
   21    33        SEND_VAL                                                 '%3C%251%24s+class%3D%22button%252%24s%253%24s%22%3E%254%24s%3C%2F%251%24s%3E%0A'
   22    34      > JMPZ                                                     !2, ->37
         35    >   QM_ASSIGN                                        ~16     'a'
         36      > JMP                                                      ->38
         37    >   QM_ASSIGN                                        ~16     'span'
         38    >   SEND_VAL                                                 ~16
   23    39        FETCH_IS                                         ~17     '_GET'
         40        FETCH_DIM_IS                                     ~18     ~17, 'sortBy'
         41        COALESCE                                         ~19     ~18
         42        QM_ASSIGN                                        ~19     '_'
         43        IS_IDENTICAL                                             !3, ~19
         44      > JMPZ                                                     ~20, ->47
         45    >   QM_ASSIGN                                        ~21     '+selected'
         46      > JMP                                                      ->48
         47    >   QM_ASSIGN                                        ~21     ''
         48    >   SEND_VAL                                                 ~21
   24    49      > JMPZ                                                     !2, ->61
         50    >   INIT_FCALL                                               'get_permalink'
         51        DO_FCALL                                      0  $22     
         52        CONCAT                                           ~23     '%22+href%3D%22', $22
         53        CONCAT                                           ~24     ~23, '%3F'
         54        INIT_FCALL                                               'http_build_query'
         55        INIT_ARRAY                                       ~25     !3, 'sortby'
         56        SEND_VAL                                                 ~25
         57        DO_ICALL                                         $26     
         58        CONCAT                                           ~27     ~24, $26
         59        QM_ASSIGN                                        ~28     ~27
         60      > JMP                                                      ->62
         61    >   QM_ASSIGN                                        ~28     '+disable'
         62    >   SEND_VAL                                                 ~28
   25    63        INIT_FCALL                                               'esc_html'
         64        SEND_VAR                                                 !3
         65        DO_FCALL                                      0  $29     
         66        SEND_VAR                                                 $29
   20    67        DO_ICALL                                                 
   19    68      > JMP                                                      ->30
         69    >   FE_FREE                                                  $13
   28    70      > RETURN                                                   null

End of function alpha_pagination

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.71 ms | 1017 KiB | 25 Q