3v4l.org

run code in 300+ PHP versions simultaneously
<?php $closures = array(); $simple_closure = function($msg="hello world") { return $msg;}; for ($x=0; $x < 2; $x++) { $closures[$x] = $simple_closure; } $obj1 = new stdClass; $obj1->msg = "top of the morning"; $obj2 = new stdClass; $obj2->msg = "joy to the world"; $c1 = Closure::bind($closures[0], $obj1); $c2 = Closure::bind($closures[1], $obj2); var_dump($c1,$c2); echo $c1($this->msg); echo $c2($this->msg);
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/tMPCh
function name:  (null)
number of ops:  51
compiled vars:  !0 = $closures, !1 = $simple_closure, !2 = $x, !3 = $obj1, !4 = $obj2, !5 = $c1, !6 = $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%2FtMPCh%3A5%240'
          2        ASSIGN                                                   !1, ~8
    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                                                    ~13, ->5
   11    10    >   NEW                                              $14     'stdClass'
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !3, $14
   12    13        ASSIGN_OBJ                                               !3, 'msg'
         14        OP_DATA                                                  'top+of+the+morning'
   14    15        NEW                                              $18     'stdClass'
         16        DO_FCALL                                      0          
         17        ASSIGN                                                   !4, $18
   15    18        ASSIGN_OBJ                                               !4, 'msg'
         19        OP_DATA                                                  'joy+to+the+world'
   17    20        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
         21        FETCH_DIM_R                                      ~22     !0, 0
         22        SEND_VAL                                                 ~22
         23        SEND_VAR                                                 !3
         24        DO_FCALL                                      0  $23     
         25        ASSIGN                                                   !5, $23
   18    26        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
         27        FETCH_DIM_R                                      ~25     !0, 1
         28        SEND_VAL                                                 ~25
         29        SEND_VAR                                                 !4
         30        DO_FCALL                                      0  $26     
         31        ASSIGN                                                   !6, $26
   20    32        INIT_FCALL                                               'var_dump'
         33        SEND_VAR                                                 !5
         34        SEND_VAR                                                 !6
         35        DO_ICALL                                                 
   22    36        INIT_DYNAMIC_CALL                                        !5
         37        CHECK_FUNC_ARG                                           
         38        FETCH_THIS                                       $29     
         39        FETCH_OBJ_FUNC_ARG                               $30     $29, 'msg'
         40        SEND_FUNC_ARG                                            $30
         41        DO_FCALL                                      0  $31     
         42        ECHO                                                     $31
   23    43        INIT_DYNAMIC_CALL                                        !6
         44        CHECK_FUNC_ARG                                           
         45        FETCH_THIS                                       $32     
         46        FETCH_OBJ_FUNC_ARG                               $33     $32, 'msg'
         47        SEND_FUNC_ARG                                            $33
         48        DO_FCALL                                      0  $34     
         49        ECHO                                                     $34
         50      > RETURN                                                   1

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

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.78 ms | 1400 KiB | 15 Q