3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $bar = 0; public function getBar() { return $this->bar; } public function getCall() { $x = &$this->bar; return function() use (&$x) { $x++; }; } } $y = new Foo; echo $y->getBar() . "\n"; $z = $y->getCall(); $z(); echo $y->getBar() . "\n"; $z(); $z(); $z(); $z(); echo $y->getBar() . "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tTqNS
function name:  (null)
number of ops:  29
compiled vars:  !0 = $y, !1 = $z
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   NEW                                              $2      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   21     3        INIT_METHOD_CALL                                         !0, 'getBar'
          4        DO_FCALL                                      0  $5      
          5        CONCAT                                           ~6      $5, '%0A'
          6        ECHO                                                     ~6
   23     7        INIT_METHOD_CALL                                         !0, 'getCall'
          8        DO_FCALL                                      0  $7      
          9        ASSIGN                                                   !1, $7
   24    10        INIT_DYNAMIC_CALL                                        !1
         11        DO_FCALL                                      0          
   25    12        INIT_METHOD_CALL                                         !0, 'getBar'
         13        DO_FCALL                                      0  $10     
         14        CONCAT                                           ~11     $10, '%0A'
         15        ECHO                                                     ~11
   26    16        INIT_DYNAMIC_CALL                                        !1
         17        DO_FCALL                                      0          
   27    18        INIT_DYNAMIC_CALL                                        !1
         19        DO_FCALL                                      0          
   28    20        INIT_DYNAMIC_CALL                                        !1
         21        DO_FCALL                                      0          
   29    22        INIT_DYNAMIC_CALL                                        !1
         23        DO_FCALL                                      0          
   30    24        INIT_METHOD_CALL                                         !0, 'getBar'
         25        DO_FCALL                                      0  $16     
         26        CONCAT                                           ~17     $16, '%0A'
         27        ECHO                                                     ~17
         28      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FtTqNS%3A16%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tTqNS
function name:  {closure}
number of ops:  3
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   BIND_STATIC                                              !0
          1        PRE_INC                                                  !0
          2      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FtTqNS%3A16%240

Class Foo:
Function getbar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tTqNS
function name:  getBar
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   FETCH_OBJ_R                                      ~0      'bar'
          1      > RETURN                                                   ~0
   10     2*     > RETURN                                                   null

End of function getbar

Function getcall:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tTqNS
function name:  getCall
number of ops:  6
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   FETCH_OBJ_W                                      $1      'bar'
          1        ASSIGN_REF                                               !0, $1
   16     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FtTqNS%3A16%240'
          3        BIND_LEXICAL                                             ~3, !0
          4      > RETURN                                                   ~3
   17     5*     > RETURN                                                   null

End of function getcall

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.46 ms | 1399 KiB | 13 Q