3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { public function foo() { echo "I am only called once.\n"; return array('a', 'b', 'c', 'd', 'e'); } public function count($arr) { echo "I am only called once.\n"; return count($arr); } } $test = new Test(); foreach ($test->foo() as $value) { echo $value . "\n"; } $arr = array(1,2,3,4,5); for($i=0; $i < $test->count($arr); ++$i) { echo $arr[$i] . "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 14
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 14
Branch analysis from position: 23
Branch analysis from position: 14
Branch analysis from position: 10
filename:       /in/TXIcK
function name:  (null)
number of ops:  24
compiled vars:  !0 = $test, !1 = $value, !2 = $arr, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   NEW                                              $4      'Test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $4
   20     3        INIT_METHOD_CALL                                         !0, 'foo'
          4        DO_FCALL                                      0  $7      
          5      > FE_RESET_R                                       $8      $7, ->10
          6    > > FE_FETCH_R                                               $8, !1, ->10
   21     7    >   CONCAT                                           ~9      !1, '%0A'
          8        ECHO                                                     ~9
   20     9      > JMP                                                      ->6
         10    >   FE_FREE                                                  $8
   24    11        ASSIGN                                                   !2, <array>
   25    12        ASSIGN                                                   !3, 0
         13      > JMP                                                      ->18
   26    14    >   FETCH_DIM_R                                      ~12     !2, !3
         15        CONCAT                                           ~13     ~12, '%0A'
         16        ECHO                                                     ~13
   25    17        PRE_INC                                                  !3
         18    >   INIT_METHOD_CALL                                         !0, 'count'
         19        SEND_VAR_EX                                              !2
         20        DO_FCALL                                      0  $15     
         21        IS_SMALLER                                               !3, $15
         22      > JMPNZ                                                    ~16, ->14
   27    23    > > RETURN                                                   1

Class Test:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TXIcK
function name:  foo
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ECHO                                                     'I+am+only+called+once.%0A'
    9     1      > RETURN                                                   <array>
   10     2*     > RETURN                                                   null

End of function foo

Function count:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TXIcK
function name:  count
number of ops:  5
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   14     1        ECHO                                                     'I+am+only+called+once.%0A'
   15     2        COUNT                                            ~1      !0
          3      > RETURN                                                   ~1
   16     4*     > RETURN                                                   null

End of function count

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.84 ms | 1399 KiB | 13 Q