3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public function getFunc($text) { return function() use ($text) { $withNewLine = $text.PHP_EOL; printf("From the inside: %s", $withNewLine); return $withNewLine; }; } } $b = new A(); $func = $b->getFunc('can i has var'); $func(); $c = ($b->getFunc('can i has var'))(); echo 'From the outside:'.PHP_EOL; echo $c;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fo2T9
function name:  (null)
number of ops:  18
compiled vars:  !0 = $b, !1 = $func, !2 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   NEW                                              $3      'A'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   19     3        INIT_METHOD_CALL                                         !0, 'getFunc'
          4        SEND_VAL_EX                                              'can+i+has+var'
          5        DO_FCALL                                      0  $6      
          6        ASSIGN                                                   !1, $6
   20     7        INIT_DYNAMIC_CALL                                        !1
          8        DO_FCALL                                      0          
   22     9        INIT_METHOD_CALL                                         !0, 'getFunc'
         10        SEND_VAL_EX                                              'can+i+has+var'
         11        DO_FCALL                                      0  $9      
         12        INIT_DYNAMIC_CALL                                        $9
         13        DO_FCALL                                      0  $10     
         14        ASSIGN                                                   !2, $10
   24    15        ECHO                                                     'From+the+outside%3A%0A'
   25    16        ECHO                                                     !2
         17      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Ffo2T9%3A7%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fo2T9
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $text, !1 = $withNewLine
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   BIND_STATIC                                              !0
    8     1        CONCAT                                           ~2      !0, '%0A'
          2        ASSIGN                                                   !1, ~2
   10     3        INIT_FCALL                                               'printf'
          4        SEND_VAL                                                 'From+the+inside%3A+%25s'
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                                 
   12     7      > RETURN                                                   !1
   13     8*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Ffo2T9%3A7%240

Class A:
Function getfunc:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fo2T9
function name:  getFunc
number of ops:  5
compiled vars:  !0 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Ffo2T9%3A7%240'
          2        BIND_LEXICAL                                             ~1, !0
   13     3      > RETURN                                                   ~1
   14     4*     > RETURN                                                   null

End of function getfunc

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.33 ms | 1400 KiB | 16 Q