3v4l.org

run code in 300+ PHP versions simultaneously
<?php class x { private $p = 'secret'; } $o = new x; $f = function(){ return $this->p; }; $g = $f; Closure::bind($f,$o); echo $f->__invoke(),"\n"; echo $f(),"\n"; echo $g->call($o);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/l2Fmn
function name:  (null)
number of ops:  23
compiled vars:  !0 = $o, !1 = $f, !2 = $g
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   NEW                                              $3      'x'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
    6     3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fl2Fmn%3A6%240'
          4        ASSIGN                                                   !1, ~6
    7     5        ASSIGN                                                   !2, !1
    8     6        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
          7        SEND_VAR                                                 !1
          8        SEND_VAR                                                 !0
          9        DO_FCALL                                      0          
    9    10        INIT_METHOD_CALL                                         !1, '__invoke'
         11        DO_FCALL                                      0  $10     
         12        ECHO                                                     $10
         13        ECHO                                                     '%0A'
   10    14        INIT_DYNAMIC_CALL                                        !1
         15        DO_FCALL                                      0  $11     
         16        ECHO                                                     $11
         17        ECHO                                                     '%0A'
   11    18        INIT_METHOD_CALL                                         !2, 'call'
         19        SEND_VAR_EX                                              !0
         20        DO_FCALL                                      0  $12     
         21        ECHO                                                     $12
         22      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Fl2Fmn%3A6%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/l2Fmn
function name:  {closure}
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   FETCH_THIS                                       $0      
          1        FETCH_OBJ_R                                      ~1      $0, 'p'
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fl2Fmn%3A6%240

Class x: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.81 ms | 1395 KiB | 13 Q