3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $a = ['a', 'b', 'c']; public function count() { return count($this->a); } public function get($i) { return $this->a[$i]; } } $foo = new Foo; echo 'Missing "a" (last record) and fails first record as count() is 1 position higher than total indexes' . \PHP_EOL; for($i = $foo->count(); $i > 0; $i--){ echo $foo->get($i) . \PHP_EOL; } echo \PHP_EOL . '---' . \PHP_EOL . \PHP_EOL; for($i = $foo->count()-1; $i >= 0; $i--){ echo $foo->get($i) . \PHP_EOL; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 8
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 22
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 22
Branch analysis from position: 30
Branch analysis from position: 22
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 8
Branch analysis from position: 16
Branch analysis from position: 8
filename:       /in/tQPPB
function name:  (null)
number of ops:  31
compiled vars:  !0 = $foo, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   NEW                                              $2      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   19     3        ECHO                                                     'Missing+%22a%22+%28last+record%29+and+fails+first+record+as+count%28%29+is+1+position+higher+than+total+indexes%0A'
   20     4        INIT_METHOD_CALL                                         !0, 'count'
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !1, $5
          7      > JMP                                                      ->14
   21     8    >   INIT_METHOD_CALL                                         !0, 'get'
          9        SEND_VAR_EX                                              !1
         10        DO_FCALL                                      0  $7      
         11        CONCAT                                           ~8      $7, '%0A'
         12        ECHO                                                     ~8
   20    13        PRE_DEC                                                  !1
         14    >   IS_SMALLER                                               0, !1
         15      > JMPNZ                                                    ~10, ->8
   23    16    >   ECHO                                                     '%0A---%0A%0A'
   24    17        INIT_METHOD_CALL                                         !0, 'count'
         18        DO_FCALL                                      0  $11     
         19        SUB                                              ~12     $11, 1
         20        ASSIGN                                                   !1, ~12
         21      > JMP                                                      ->28
   25    22    >   INIT_METHOD_CALL                                         !0, 'get'
         23        SEND_VAR_EX                                              !1
         24        DO_FCALL                                      0  $14     
         25        CONCAT                                           ~15     $14, '%0A'
         26        ECHO                                                     ~15
   24    27        PRE_DEC                                                  !1
         28    >   IS_SMALLER_OR_EQUAL                                      0, !1
         29      > JMPNZ                                                    ~17, ->22
   26    30    > > RETURN                                                   1

Class Foo:
Function count:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tQPPB
function name:  count
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   FETCH_OBJ_R                                      ~0      'a'
          1        COUNT                                            ~1      ~0
          2      > RETURN                                                   ~1
   10     3*     > RETURN                                                   null

End of function count

Function get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tQPPB
function name:  get
number of ops:  5
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   14     1        FETCH_OBJ_R                                      ~1      'a'
          2        FETCH_DIM_R                                      ~2      ~1, !0
          3      > RETURN                                                   ~2
   15     4*     > RETURN                                                   null

End of function get

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
134.38 ms | 1012 KiB | 13 Q