3v4l.org

run code in 300+ PHP versions simultaneously
<?php global $smarty; $itemCount = 0; $productKeys = array('domains', 'other', 'stuff'); $language = $smarty->get_template_vars('language'); foreach ($productKeys as $productKey) { if (!empty($_SESSION['cart'][$productKey])) { $itemCount += count($_SESSION['cart'][$productKey]); } } if (($itemCount += count($_SESSION['cart'][$productKey])) > 1): echo "<a href='https://mysite.com/checkout/go'><li class='header-icon'><div class='header-right-icon-cart'></div></li>"; if ($language == us) { echo "<li class='header-right-chat'>{$itemCount} items</li></a>"; } else { echo "<li class='header-right-chat'>{$itemCount} itens</li></a>"; } elseif (($itemCount += count($_SESSION['cart'][$productKey])) == 1): echo "<a href='https://mysite.com/checkout/go'><li class='header-icon'><div class='header-right-icon-cart'></div></li>"; echo "<li class='header-right-chat'>{$itemCount} item</li></a>"; endif; ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 20
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 20
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 19
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 19
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 42
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 37
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 54
Branch analysis from position: 54
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 54
Branch analysis from position: 54
Branch analysis from position: 42
2 jumps found. (Code = 43) Position 1 = 49, Position 2 = 54
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 54
Branch analysis from position: 20
filename:       /in/53dUH
function name:  (null)
number of ops:  55
compiled vars:  !0 = $smarty, !1 = $itemCount, !2 = $productKeys, !3 = $language, !4 = $productKey
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   BIND_GLOBAL                                              !0, 'smarty'
    3     1        ASSIGN                                                   !1, 0
    4     2        ASSIGN                                                   !2, <array>
    5     3        INIT_METHOD_CALL                                         !0, 'get_template_vars'
          4        SEND_VAL_EX                                              'language'
          5        DO_FCALL                                      0  $7      
          6        ASSIGN                                                   !3, $7
    6     7      > FE_RESET_R                                       $9      !2, ->20
          8    > > FE_FETCH_R                                               $9, !4, ->20
    8     9    >   FETCH_IS                                         ~10     '_SESSION'
         10        FETCH_DIM_IS                                     ~11     ~10, 'cart'
         11        ISSET_ISEMPTY_DIM_OBJ                         1  ~12     ~11, !4
         12        BOOL_NOT                                         ~13     ~12
         13      > JMPZ                                                     ~13, ->19
   10    14    >   FETCH_R                      global              ~14     '_SESSION'
         15        FETCH_DIM_R                                      ~15     ~14, 'cart'
         16        FETCH_DIM_R                                      ~16     ~15, !4
         17        COUNT                                            ~17     ~16
         18        ASSIGN_OP                                     1          !1, ~17
    6    19    > > JMP                                                      ->8
         20    >   FE_FREE                                                  $9
   13    21        FETCH_R                      global              ~19     '_SESSION'
         22        FETCH_DIM_R                                      ~20     ~19, 'cart'
         23        FETCH_DIM_R                                      ~21     ~20, !4
         24        COUNT                                            ~22     ~21
         25        ASSIGN_OP                                     1  ~23     !1, ~22
         26        IS_SMALLER                                               1, ~23
         27      > JMPZ                                                     ~24, ->42
   14    28    >   ECHO                                                     '%3Ca+href%3D%27https%3A%2F%2Fmysite.com%2Fcheckout%2Fgo%27%3E%3Cli+class%3D%27header-icon%27%3E%3Cdiv+class%3D%27header-right-icon-cart%27%3E%3C%2Fdiv%3E%3C%2Fli%3E'
   15    29        FETCH_CONSTANT                                   ~25     'us'
         30        IS_EQUAL                                                 !3, ~25
         31      > JMPZ                                                     ~26, ->37
   16    32    >   ROPE_INIT                                     3  ~28     '%3Cli+class%3D%27header-right-chat%27%3E'
         33        ROPE_ADD                                      1  ~28     ~28, !1
         34        ROPE_END                                      2  ~27     ~28, '+items%3C%2Fli%3E%3C%2Fa%3E'
         35        ECHO                                                     ~27
         36      > JMP                                                      ->41
   18    37    >   ROPE_INIT                                     3  ~31     '%3Cli+class%3D%27header-right-chat%27%3E'
         38        ROPE_ADD                                      1  ~31     ~31, !1
         39        ROPE_END                                      2  ~30     ~31, '+itens%3C%2Fli%3E%3C%2Fa%3E'
         40        ECHO                                                     ~30
         41    > > JMP                                                      ->54
   20    42    >   FETCH_R                      global              ~33     '_SESSION'
         43        FETCH_DIM_R                                      ~34     ~33, 'cart'
         44        FETCH_DIM_R                                      ~35     ~34, !4
         45        COUNT                                            ~36     ~35
         46        ASSIGN_OP                                     1  ~37     !1, ~36
         47        IS_EQUAL                                                 ~37, 1
         48      > JMPZ                                                     ~38, ->54
   21    49    >   ECHO                                                     '%3Ca+href%3D%27https%3A%2F%2Fmysite.com%2Fcheckout%2Fgo%27%3E%3Cli+class%3D%27header-icon%27%3E%3Cdiv+class%3D%27header-right-icon-cart%27%3E%3C%2Fdiv%3E%3C%2Fli%3E'
   22    50        ROPE_INIT                                     3  ~40     '%3Cli+class%3D%27header-right-chat%27%3E'
         51        ROPE_ADD                                      1  ~40     ~40, !1
         52        ROPE_END                                      2  ~39     ~40, '+item%3C%2Fli%3E%3C%2Fa%3E'
         53        ECHO                                                     ~39
   24    54    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.75 ms | 1399 KiB | 13 Q