3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Record { protected $index=0; //page index protected $pages=[]; //pages array public function nextPage() { $this->index++; } public function addRecord($key, $value) { $this->pages[$this->index][$key] = $value; } public function getPage($index) { if ($index > $this->index) return NULL; else return $this->pages[$this->index]; } } class AdditiveRecord extends Record { public function getSums($range) { $sums = $this->pages[$range[0]]; $lim = ($range[1] <= $this->index) ? $range[1] : $this->index; echo $lim; echo $index; for ($i = $range[0]+1;$i<=$lim;$i++) { foreach($this->pages[$i] as $k=>$v) $sums[$k] += $v; } return $sums; } } $m = new AdditiveRecord(); for ($j = 1;$j<3;$j++) { for ($i = 1;$i<10;$i++) $m->addRecord($i,$j*10+$i); $m->nextPage(); } var_dump($m->getSums([0,2]));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 5
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 7
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 5
Branch analysis from position: 21
Branch analysis from position: 5
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 7
Branch analysis from position: 16
Branch analysis from position: 7
filename:       /in/eFFek
function name:  (null)
number of ops:  28
compiled vars:  !0 = $m, !1 = $j, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   NEW                                              $3      'AdditiveRecord'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   36     3        ASSIGN                                                   !1, 1
          4      > JMP                                                      ->19
   37     5    >   ASSIGN                                                   !2, 1
          6      > JMP                                                      ->14
   38     7    >   INIT_METHOD_CALL                                         !0, 'addRecord'
          8        SEND_VAR_EX                                              !2
          9        MUL                                              ~8      !1, 10
         10        ADD                                              ~9      ~8, !2
         11        SEND_VAL_EX                                              ~9
         12        DO_FCALL                                      0          
   37    13        PRE_INC                                                  !2
         14    >   IS_SMALLER                                               !2, 10
         15      > JMPNZ                                                    ~12, ->7
   39    16    >   INIT_METHOD_CALL                                         !0, 'nextPage'
         17        DO_FCALL                                      0          
   36    18        PRE_INC                                                  !1
         19    >   IS_SMALLER                                               !1, 3
         20      > JMPNZ                                                    ~15, ->5
   41    21    >   INIT_FCALL                                               'var_dump'
         22        INIT_METHOD_CALL                                         !0, 'getSums'
         23        SEND_VAL_EX                                              <array>
         24        DO_FCALL                                      0  $16     
         25        SEND_VAR                                                 $16
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

Class Record:
Function nextpage:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eFFek
function name:  nextPage
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   PRE_INC_OBJ                                              'index'
    9     1      > RETURN                                                   null

End of function nextpage

Function addrecord:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eFFek
function name:  addRecord
number of ops:  8
compiled vars:  !0 = $key, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        FETCH_OBJ_R                                      ~3      'index'
          3        FETCH_OBJ_W                                      $2      'pages'
          4        FETCH_DIM_W                                      $4      $2, ~3
          5        ASSIGN_DIM                                               $4, !0
          6        OP_DATA                                                  !1
   12     7      > RETURN                                                   null

End of function addrecord

Function getpage:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eFFek
function name:  getPage
number of ops:  11
compiled vars:  !0 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        FETCH_OBJ_R                                      ~1      'index'
          2        IS_SMALLER                                               ~1, !0
          3      > JMPZ                                                     ~2, ->6
   15     4    > > RETURN                                                   null
          5*       JMP                                                      ->10
   17     6    >   FETCH_OBJ_R                                      ~4      'index'
          7        FETCH_OBJ_R                                      ~3      'pages'
          8        FETCH_DIM_R                                      ~5      ~3, ~4
          9      > RETURN                                                   ~5
   18    10*     > RETURN                                                   null

End of function getpage

End of class Record.

Class AdditiveRecord:
Function getsums:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 21
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 29
Branch analysis from position: 24
2 jumps found. (Code = 78) Position 1 = 25, Position 2 = 29
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 21
Branch analysis from position: 33
Branch analysis from position: 21
Branch analysis from position: 29
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
filename:       /in/eFFek
function name:  getSums
number of ops:  35
compiled vars:  !0 = $range, !1 = $sums, !2 = $lim, !3 = $index, !4 = $i, !5 = $v, !6 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
   23     1        FETCH_DIM_R                                      ~8      !0, 0
          2        FETCH_OBJ_R                                      ~7      'pages'
          3        FETCH_DIM_R                                      ~9      ~7, ~8
          4        ASSIGN                                                   !1, ~9
   24     5        FETCH_DIM_R                                      ~11     !0, 1
          6        FETCH_OBJ_R                                      ~12     'index'
          7        IS_SMALLER_OR_EQUAL                                      ~11, ~12
          8      > JMPZ                                                     ~13, ->12
          9    >   FETCH_DIM_R                                      ~14     !0, 1
         10        QM_ASSIGN                                        ~15     ~14
         11      > JMP                                                      ->14
         12    >   FETCH_OBJ_R                                      ~16     'index'
         13        QM_ASSIGN                                        ~15     ~16
         14    >   ASSIGN                                                   !2, ~15
   25    15        ECHO                                                     !2
   26    16        ECHO                                                     !3
   27    17        FETCH_DIM_R                                      ~18     !0, 0
         18        ADD                                              ~19     ~18, 1
         19        ASSIGN                                                   !4, ~19
         20      > JMP                                                      ->31
   28    21    >   FETCH_OBJ_R                                      ~21     'pages'
         22        FETCH_DIM_R                                      ~22     ~21, !4
         23      > FE_RESET_R                                       $23     ~22, ->29
         24    > > FE_FETCH_R                                       ~24     $23, !5, ->29
         25    >   ASSIGN                                                   !6, ~24
   29    26        ASSIGN_DIM_OP                +=               1          !1, !6
         27        OP_DATA                                                  !5
   28    28      > JMP                                                      ->24
         29    >   FE_FREE                                                  $23
   27    30        PRE_INC                                                  !4
         31    >   IS_SMALLER_OR_EQUAL                                      !4, !2
         32      > JMPNZ                                                    ~28, ->21
   31    33    > > RETURN                                                   !1
   32    34*     > RETURN                                                   null

End of function getsums

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

End of function nextpage

Function addrecord:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eFFek
function name:  addRecord
number of ops:  8
compiled vars:  !0 = $key, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        FETCH_OBJ_R                                      ~3      'index'
          3        FETCH_OBJ_W                                      $2      'pages'
          4        FETCH_DIM_W                                      $4      $2, ~3
          5        ASSIGN_DIM                                               $4, !0
          6        OP_DATA                                                  !1
   12     7      > RETURN                                                   null

End of function addrecord

Function getpage:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eFFek
function name:  getPage
number of ops:  11
compiled vars:  !0 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        FETCH_OBJ_R                                      ~1      'index'
          2        IS_SMALLER                                               ~1, !0
          3      > JMPZ                                                     ~2, ->6
   15     4    > > RETURN                                                   null
          5*       JMP                                                      ->10
   17     6    >   FETCH_OBJ_R                                      ~4      'index'
          7        FETCH_OBJ_R                                      ~3      'pages'
          8        FETCH_DIM_R                                      ~5      ~3, ~4
          9      > RETURN                                                   ~5
   18    10*     > RETURN                                                   null

End of function getpage

End of class AdditiveRecord.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.17 ms | 1408 KiB | 15 Q