3v4l.org

run code in 300+ PHP versions simultaneously
<?php $closures = array(); $simple_closure = function() { return $this->msg;}; for ($x=0; $x < 2; $x++) { $closures[$x] = $simple_closure; } $obj1 = new stdClass; $obj1->msg = "Top of the morning\n"; $obj1->getEveningMessage = function () { return "Some enchanted evening ...\n"; }; $m = $obj1->getEveningMessage; echo $m(); $obj2 = clone($obj1); $obj2->msg = "Happy Days!\n"; $n = $obj2->getEveningMessage; echo $n(); $c1 = Closure::bind($closures[0], $obj1); $c2 = Closure::bind($closures[1], $obj2); echo $c1(); echo $c2(); $obj1->getEveningMessage = function () { return "Some enchanted evening ...\n"; }; $m = $obj1->getEveningMessage; echo $m(); $n = $obj2->getEveningMessage; echo $n();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 5
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 5
Branch analysis from position: 10
Branch analysis from position: 5
filename:       /in/g0aqG
function name:  (null)
number of ops:  64
compiled vars:  !0 = $closures, !1 = $simple_closure, !2 = $x, !3 = $obj1, !4 = $m, !5 = $obj2, !6 = $n, !7 = $c1, !8 = $c2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fg0aqG%3A5%240'
          2        ASSIGN                                                   !1, ~10
    7     3        ASSIGN                                                   !2, 0
          4      > JMP                                                      ->8
    8     5    >   ASSIGN_DIM                                               !0, !2
          6        OP_DATA                                                  !1
    7     7        PRE_INC                                                  !2
          8    >   IS_SMALLER                                               !2, 2
          9      > JMPNZ                                                    ~15, ->5
   11    10    >   NEW                                              $16     'stdClass'
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !3, $16
   12    13        ASSIGN_OBJ                                               !3, 'msg'
         14        OP_DATA                                                  'Top+of+the+morning%0A'
   13    15        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fg0aqG%3A13%241'
         16        ASSIGN_OBJ                                               !3, 'getEveningMessage'
         17        OP_DATA                                                  ~21
   14    18        FETCH_OBJ_R                                      ~22     !3, 'getEveningMessage'
         19        ASSIGN                                                   !4, ~22
   15    20        INIT_DYNAMIC_CALL                                        !4
         21        DO_FCALL                                      0  $24     
         22        ECHO                                                     $24
   17    23        CLONE                                            ~25     !3
         24        ASSIGN                                                   !5, ~25
   18    25        ASSIGN_OBJ                                               !5, 'msg'
         26        OP_DATA                                                  'Happy+Days%21%0A'
   19    27        FETCH_OBJ_R                                      ~28     !5, 'getEveningMessage'
         28        ASSIGN                                                   !6, ~28
   20    29        INIT_DYNAMIC_CALL                                        !6
         30        DO_FCALL                                      0  $30     
         31        ECHO                                                     $30
   22    32        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
         33        FETCH_DIM_R                                      ~31     !0, 0
         34        SEND_VAL                                                 ~31
         35        SEND_VAR                                                 !3
         36        DO_FCALL                                      0  $32     
         37        ASSIGN                                                   !7, $32
   23    38        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
         39        FETCH_DIM_R                                      ~34     !0, 1
         40        SEND_VAL                                                 ~34
         41        SEND_VAR                                                 !5
         42        DO_FCALL                                      0  $35     
         43        ASSIGN                                                   !8, $35
   25    44        INIT_DYNAMIC_CALL                                        !7
         45        DO_FCALL                                      0  $37     
         46        ECHO                                                     $37
   26    47        INIT_DYNAMIC_CALL                                        !8
         48        DO_FCALL                                      0  $38     
         49        ECHO                                                     $38
   28    50        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fg0aqG%3A28%242'
         51        ASSIGN_OBJ                                               !3, 'getEveningMessage'
         52        OP_DATA                                                  ~40
   29    53        FETCH_OBJ_R                                      ~41     !3, 'getEveningMessage'
         54        ASSIGN                                                   !4, ~41
   30    55        INIT_DYNAMIC_CALL                                        !4
         56        DO_FCALL                                      0  $43     
         57        ECHO                                                     $43
   32    58        FETCH_OBJ_R                                      ~44     !5, 'getEveningMessage'
         59        ASSIGN                                                   !6, ~44
   33    60        INIT_DYNAMIC_CALL                                        !6
         61        DO_FCALL                                      0  $46     
         62        ECHO                                                     $46
         63      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2Fg0aqG%3A5%240

Function %00%7Bclosure%7D%2Fin%2Fg0aqG%3A13%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g0aqG
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E > > RETURN                                                   'Some+enchanted+evening+...%0A'
          1*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fg0aqG%3A13%241

Function %00%7Bclosure%7D%2Fin%2Fg0aqG%3A28%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g0aqG
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E > > RETURN                                                   'Some+enchanted+evening+...%0A'
          1*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fg0aqG%3A28%242

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.69 ms | 1394 KiB | 13 Q