3v4l.org

run code in 300+ PHP versions simultaneously
<?php class CountHelper { public static function count_if_you_can($var) { if (is_array($var)) { return count($var); } elseif (is_object($var)) { if ($var instanceof Countable) { return count($var); } else { return 1; } } elseif ($var === NULL) { return 0; } else { return 1; } } } function teste($var) { $result = CountHelper::count_if_you_can($var); var_dump($result); $result = sizeof($var); var_dump($result); if (count($var) > 0){ foreach ($var as $v) { echo $v; } } } echo teste('');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BEbSE
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   52     0  E >   INIT_FCALL                                               'teste'
          1        SEND_VAL                                                 ''
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function teste:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 21
Branch analysis from position: 16
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 20
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
Branch analysis from position: 21
filename:       /in/BEbSE
function name:  teste
number of ops:  22
compiled vars:  !0 = $var, !1 = $result, !2 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
   37     1        INIT_STATIC_METHOD_CALL                                  'CountHelper', 'count_if_you_can'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $3      
          4        ASSIGN                                                   !1, $3
   38     5        INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                                 
   40     8        COUNT                                            ~6      !0
          9        ASSIGN                                                   !1, ~6
   41    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                                 
   43    13        COUNT                                            ~9      !0
         14        IS_SMALLER                                               0, ~9
         15      > JMPZ                                                     ~10, ->21
   44    16    > > FE_RESET_R                                       $11     !0, ->20
         17    > > FE_FETCH_R                                               $11, !2, ->20
   46    18    >   ECHO                                                     !2
   44    19      > JMP                                                      ->17
         20    >   FE_FREE                                                  $11
   49    21    > > RETURN                                                   null

End of function teste

Class CountHelper:
Function count_if_you_can:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 15
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BEbSE
function name:  count_if_you_can
number of ops:  21
compiled vars:  !0 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    8     1        TYPE_CHECK                                  128          !0
          2      > JMPZ                                                     ~1, ->6
   10     3    >   COUNT                                            ~2      !0
          4      > RETURN                                                   ~2
          5*       JMP                                                      ->20
   12     6    >   TYPE_CHECK                                  256          !0
          7      > JMPZ                                                     ~3, ->15
   14     8    >   INSTANCEOF                                               !0, 'Countable'
          9      > JMPZ                                                     ~4, ->13
   16    10    >   COUNT                                            ~5      !0
         11      > RETURN                                                   ~5
         12*       JMP                                                      ->14
   20    13    > > RETURN                                                   1
         14*       JMP                                                      ->20
   23    15    >   TYPE_CHECK                                    2          !0
         16      > JMPZ                                                     ~6, ->19
   25    17    > > RETURN                                                   0
         18*       JMP                                                      ->20
   29    19    > > RETURN                                                   1
   31    20*     > RETURN                                                   null

End of function count_if_you_can

End of class CountHelper.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.29 ms | 1402 KiB | 16 Q