3v4l.org

run code in 300+ PHP versions simultaneously
<?php function foo1() { echo __FUNCTION__, "\n"; } class Foo { function do_foo() { echo __METHOD__, "\n"; } static function static_foo() { echo __METHOD__, "\n"; } } $funs = array( 'foo1', // function array(new Foo(), 'do_foo'), // object method array('Foo', 'static_foo'), // static class method function () { echo __FUNCTION__, "\n"; }, // anonymous function ); echo "call_user_func():\n"; foreach ($funs as $fun) { echo "\t"; call_user_func($fun); } echo "\ndirect call():\n"; foreach ($funs as $fun) { echo "\t"; $fun(); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 17
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 17
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 17
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 25
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 25
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
Branch analysis from position: 17
filename:       /in/DuL2X
function name:  (null)
number of ops:  27
compiled vars:  !0 = $funs, !1 = $fun
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_ARRAY                                       ~2      'foo1'
   13     1        NEW                                              $3      'Foo'
          2        DO_FCALL                                      0          
          3        INIT_ARRAY                                       ~5      $3
          4        ADD_ARRAY_ELEMENT                                ~5      'do_foo'
          5        ADD_ARRAY_ELEMENT                                ~2      ~5
   12     6        ADD_ARRAY_ELEMENT                                ~2      <array>
   15     7        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FDuL2X%3A15%240'
          8        ADD_ARRAY_ELEMENT                                ~2      ~6
   11     9        ASSIGN                                                   !0, ~2
   19    10        ECHO                                                     'call_user_func%28%29%3A%0A'
   20    11      > FE_RESET_R                                       $8      !0, ->17
         12    > > FE_FETCH_R                                               $8, !1, ->17
   21    13    >   ECHO                                                     '%09'
         14        INIT_USER_CALL                                0          'call_user_func', !1
         15        DO_FCALL                                      0          
   20    16      > JMP                                                      ->12
         17    >   FE_FREE                                                  $8
   24    18        ECHO                                                     '%0Adirect+call%28%29%3A%0A'
   25    19      > FE_RESET_R                                       $10     !0, ->25
         20    > > FE_FETCH_R                                               $10, !1, ->25
   26    21    >   ECHO                                                     '%09'
         22        INIT_DYNAMIC_CALL                                        !1
         23        DO_FCALL                                      0          
   25    24      > JMP                                                      ->20
         25    >   FE_FREE                                                  $10
   27    26      > RETURN                                                   1

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

End of function foo1

Function %00%7Bclosure%7D%2Fin%2FDuL2X%3A15%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DuL2X
function name:  {closure}
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   ECHO                                                     '%7Bclosure%7D'
          1        ECHO                                                     '%0A'
          2      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FDuL2X%3A15%240

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

End of function do_foo

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

End of function static_foo

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.58 ms | 1399 KiB | 13 Q