3v4l.org

run code in 300+ PHP versions simultaneously
<?php //normal function declaration function greeting(){ return "Hellow Developers!"; } echo greeting(); echo "\n"; //function argument and parameter function addition($a,$b){ return $a+$b; } echo addition(10,20); echo "\n"; //default function argument function defaultParam($a,$b=30){ return $a+$b; } echo defaultParam(10); echo "\n"; echo defaultParam(10,25); echo "\n"; //variable scope within function $global = "I am a global variable"; function variableScope(){ echo $local = "I am a local variable"; echo "\n"; global $global ; echo $global; echo "\n"; echo $GLOBALS['global']; echo "\n"; } variableScope(); //anonymous function $anonymousFunction = function($a){ return $a*$a; }; echo $anonymousFunction(10); echo "\n"; //arrow function $arraowFunc = fn($a,$b)=>($a+$b); echo $arraowFunc(20,30); echo "\n"; //callback function function myFunc($callback){ return $callback("World"); } $result = myFunc(function($xyz){ return "Hellow, $xyz"; }); echo $result; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0VUCO
function name:  (null)
number of ops:  46
compiled vars:  !0 = $global, !1 = $anonymousFunction, !2 = $arraowFunc, !3 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   INIT_FCALL                                               'greeting'
          1        DO_FCALL                                      0  $4      
          2        ECHO                                                     $4
    9     3        ECHO                                                     '%0A'
   16     4        INIT_FCALL                                               'addition'
          5        SEND_VAL                                                 10
          6        SEND_VAL                                                 20
          7        DO_FCALL                                      0  $5      
          8        ECHO                                                     $5
   17     9        ECHO                                                     '%0A'
   24    10        INIT_FCALL                                               'defaultparam'
         11        SEND_VAL                                                 10
         12        DO_FCALL                                      0  $6      
         13        ECHO                                                     $6
   25    14        ECHO                                                     '%0A'
   26    15        INIT_FCALL                                               'defaultparam'
         16        SEND_VAL                                                 10
         17        SEND_VAL                                                 25
         18        DO_FCALL                                      0  $7      
         19        ECHO                                                     $7
   27    20        ECHO                                                     '%0A'
   31    21        ASSIGN                                                   !0, 'I+am+a+global+variable'
   42    22        INIT_FCALL                                               'variablescope'
         23        DO_FCALL                                      0          
   46    24        DECLARE_LAMBDA_FUNCTION                          ~10     [0]
         25        ASSIGN                                                   !1, ~10
   50    26        INIT_DYNAMIC_CALL                                        !1
         27        SEND_VAL_EX                                              10
         28        DO_FCALL                                      0  $12     
         29        ECHO                                                     $12
   51    30        ECHO                                                     '%0A'
   55    31        DECLARE_LAMBDA_FUNCTION                          ~13     [1]
         32        ASSIGN                                                   !2, ~13
   57    33        INIT_DYNAMIC_CALL                                        !2
         34        SEND_VAL_EX                                              20
         35        SEND_VAL_EX                                              30
         36        DO_FCALL                                      0  $15     
         37        ECHO                                                     $15
   58    38        ECHO                                                     '%0A'
   67    39        INIT_FCALL                                               'myfunc'
         40        DECLARE_LAMBDA_FUNCTION                          ~16     [2]
   69    41        SEND_VAL                                                 ~16
   67    42        DO_FCALL                                      0  $17     
         43        ASSIGN                                                   !3, $17
   71    44        ECHO                                                     !3
   74    45      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0VUCO
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   RECV                                             !0      
   47     1        MUL                                              ~1      !0, !0
          2      > RETURN                                                   ~1
   48     3*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0VUCO
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   55     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        ADD                                              ~2      !0, !1
          3      > RETURN                                                   ~2
          4*     > RETURN                                                   null

End of Dynamic Function 1

Dynamic Function 2
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0VUCO
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $xyz
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   67     0  E >   RECV                                             !0      
   68     1        NOP                                                      
          2        FAST_CONCAT                                      ~1      'Hellow%2C+', !0
          3      > RETURN                                                   ~1
   69     4*     > RETURN                                                   null

End of Dynamic Function 2

Function greeting:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0VUCO
function name:  greeting
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E > > RETURN                                                   'Hellow+Developers%21'
    6     1*     > RETURN                                                   null

End of function greeting

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

End of function addition

Function defaultparam:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0VUCO
function name:  defaultParam
number of ops:  5
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      30
   21     2        ADD                                              ~2      !0, !1
          3      > RETURN                                                   ~2
   22     4*     > RETURN                                                   null

End of function defaultparam

Function variablescope:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0VUCO
function name:  variableScope
number of ops:  10
compiled vars:  !0 = $local, !1 = $global
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   ASSIGN                                           ~2      !0, 'I+am+a+local+variable'
          1        ECHO                                                     ~2
   34     2        ECHO                                                     '%0A'
   35     3        BIND_GLOBAL                                              !1, 'global'
   36     4        ECHO                                                     !1
   37     5        ECHO                                                     '%0A'
   38     6        FETCH_R                      global              ~3      'global'
          7        ECHO                                                     ~3
   39     8        ECHO                                                     '%0A'
   40     9      > RETURN                                                   null

End of function variablescope

Function myfunc:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0VUCO
function name:  myFunc
number of ops:  6
compiled vars:  !0 = $callback
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   63     0  E >   RECV                                             !0      
   64     1        INIT_DYNAMIC_CALL                                        !0
          2        SEND_VAL_EX                                              'World'
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
   65     5*     > RETURN                                                   null

End of function myfunc

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.28 ms | 978 KiB | 19 Q