3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { private $functions = array( array('funcName' => 'FUNC1'), array('funcName' => 'FUNC2'), array('funcName' => 'FUNC3') ); function FUNC1() { echo 'FUNC1', PHP_EOL, PHP_EOL; } function FUNC2() { echo 'FUNC2', PHP_EOL, PHP_EOL; } function FUNC3() { echo 'FUNC3', PHP_EOL, PHP_EOL; } /** this worked only up to PHP 5.6.16 */ public function callAllFunctions() { foreach ($this->functions as $values) { echo 'call ', $values['funcName'], PHP_EOL; $this->$values['funcName'](); } } /** this code must be used in PHP 7.x public function callAllFunctions() { foreach ($this->functions as $values) { echo 'call ', $values['funcName'], PHP_EOL; $fncName = $values['funcName']; $this->$fncName(); } } */ } $test = new foo(); $test->callAllFunctions();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9pkEq
function name:  (null)
number of ops:  6
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   NEW                                              $1      'foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   43     3        INIT_METHOD_CALL                                         !0, 'callAllFunctions'
          4        DO_FCALL                                      0          
          5      > RETURN                                                   1

Class foo:
Function func1:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9pkEq
function name:  FUNC1
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ECHO                                                     'FUNC1'
          1        ECHO                                                     '%0A'
          2        ECHO                                                     '%0A'
   13     3      > RETURN                                                   null

End of function func1

Function func2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9pkEq
function name:  FUNC2
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   ECHO                                                     'FUNC2'
          1        ECHO                                                     '%0A'
          2        ECHO                                                     '%0A'
   17     3      > RETURN                                                   null

End of function func2

Function func3:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9pkEq
function name:  FUNC3
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   ECHO                                                     'FUNC3'
          1        ECHO                                                     '%0A'
          2        ECHO                                                     '%0A'
   21     3      > RETURN                                                   null

End of function func3

Function callallfunctions:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 12
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/9pkEq
function name:  callAllFunctions
number of ops:  14
compiled vars:  !0 = $values
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   FETCH_OBJ_R                                      ~1      'functions'
          1      > FE_RESET_R                                       $2      ~1, ->12
          2    > > FE_FETCH_R                                               $2, !0, ->12
   26     3    >   ECHO                                                     'call+'
          4        FETCH_DIM_R                                      ~3      !0, 'funcName'
          5        ECHO                                                     ~3
          6        ECHO                                                     '%0A'
   27     7        FETCH_OBJ_R                                      ~4      !0
          8        FETCH_DIM_R                                      ~5      ~4, 'funcName'
          9        INIT_DYNAMIC_CALL                                        ~5
         10        DO_FCALL                                      0          
   25    11      > JMP                                                      ->2
         12    >   FE_FREE                                                  $2
   29    13      > RETURN                                                   null

End of function callallfunctions

End of class foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.39 ms | 1399 KiB | 13 Q