3v4l.org

run code in 300+ PHP versions simultaneously
<?php $test = function () { echo 'hello world'; }; function closure_dump($closure) { try{ $func = new ReflectionFunction($closure); } catch (ReflectionException $e) { echo $e->getMessage(); return; } $start = $func->getStartLine() - 1; $end = $func->getEndLine() - 1; $filename = $func->getFileName(); echo implode("", array_slice(file($filename),$start, $end - $start + 1)); } closure_dump($test);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/39tT4
function name:  (null)
number of ops:  6
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F39tT4%3A4%240'
          1        ASSIGN                                                   !0, ~1
   28     2        INIT_FCALL                                               'closure_dump'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0          
          5      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2F39tT4%3A4%240

Function closure_dump:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 6
Branch analysis from position: 6
2 jumps found. (Code = 107) Position 1 = 7, Position 2 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/39tT4
function name:  closure_dump
number of ops:  38
compiled vars:  !0 = $closure, !1 = $func, !2 = $e, !3 = $start, !4 = $end, !5 = $filename
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
   11     1        NEW                                              $6      'ReflectionFunction'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $6
          5      > JMP                                                      ->11
   13     6  E > > CATCH                                       last         'ReflectionException'
   15     7    >   INIT_METHOD_CALL                                         !2, 'getMessage'
          8        DO_FCALL                                      0  $9      
          9        ECHO                                                     $9
   16    10      > RETURN                                                   null
   19    11    >   INIT_METHOD_CALL                                         !1, 'getStartLine'
         12        DO_FCALL                                      0  $10     
         13        SUB                                              ~11     $10, 1
         14        ASSIGN                                                   !3, ~11
   21    15        INIT_METHOD_CALL                                         !1, 'getEndLine'
         16        DO_FCALL                                      0  $13     
         17        SUB                                              ~14     $13, 1
         18        ASSIGN                                                   !4, ~14
   23    19        INIT_METHOD_CALL                                         !1, 'getFileName'
         20        DO_FCALL                                      0  $16     
         21        ASSIGN                                                   !5, $16
   25    22        INIT_FCALL                                               'implode'
         23        SEND_VAL                                                 ''
         24        INIT_FCALL                                               'array_slice'
         25        INIT_FCALL                                               'file'
         26        SEND_VAR                                                 !5
         27        DO_ICALL                                         $18     
         28        SEND_VAR                                                 $18
         29        SEND_VAR                                                 !3
         30        SUB                                              ~19     !4, !3
         31        ADD                                              ~20     ~19, 1
         32        SEND_VAL                                                 ~20
         33        DO_ICALL                                         $21     
         34        SEND_VAR                                                 $21
         35        DO_ICALL                                         $22     
         36        ECHO                                                     $22
   26    37      > RETURN                                                   null

End of function closure_dump

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155 ms | 1403 KiB | 20 Q