3v4l.org

run code in 300+ PHP versions simultaneously
<?php // objects, closures, stdClass, clone $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 and lovely summer evening ...\n"; }; $obj2 = clone($obj1); $obj2->msg = "Happy Days!\n"; $c1 = Closure::bind($closures[0], $obj1); $c2 = Closure::bind($closures[1], $obj2); echo $c1(); echo $c2(); $first = $obj1->getEveningMessage; echo $first(); echo call_user_func($first); echo $first->__invoke(); class Test extends stdClass { public $name = 'Testing'; public function __toString() { return "$this->name"; } } $t = new Test; echo $t;
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/BGjG0
function name:  (null)
number of ops:  57
compiled vars:  !0 = $closures, !1 = $simple_closure, !2 = $x, !3 = $obj1, !4 = $obj2, !5 = $c1, !6 = $c2, !7 = $first, !8 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, <array>
    6     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FBGjG0%3A6%240'
          2        ASSIGN                                                   !1, ~10
    8     3        ASSIGN                                                   !2, 0
          4      > JMP                                                      ->8
    9     5    >   ASSIGN_DIM                                               !0, !2
          6        OP_DATA                                                  !1
    8     7        PRE_INC                                                  !2
          8    >   IS_SMALLER                                               !2, 2
          9      > JMPNZ                                                    ~15, ->5
   12    10    >   NEW                                              $16     'stdClass'
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !3, $16
   13    13        ASSIGN_OBJ                                               !3, 'msg'
         14        OP_DATA                                                  'Top+of+the+morning%0A'
   14    15        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FBGjG0%3A14%241'
         16        ASSIGN_OBJ                                               !3, 'getEveningMessage'
         17        OP_DATA                                                  ~21
   16    18        CLONE                                            ~22     !3
         19        ASSIGN                                                   !4, ~22
   17    20        ASSIGN_OBJ                                               !4, 'msg'
         21        OP_DATA                                                  'Happy+Days%21%0A'
   19    22        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
         23        FETCH_DIM_R                                      ~25     !0, 0
         24        SEND_VAL                                                 ~25
         25        SEND_VAR                                                 !3
         26        DO_FCALL                                      0  $26     
         27        ASSIGN                                                   !5, $26
   20    28        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
         29        FETCH_DIM_R                                      ~28     !0, 1
         30        SEND_VAL                                                 ~28
         31        SEND_VAR                                                 !4
         32        DO_FCALL                                      0  $29     
         33        ASSIGN                                                   !6, $29
   22    34        INIT_DYNAMIC_CALL                                        !5
         35        DO_FCALL                                      0  $31     
         36        ECHO                                                     $31
   23    37        INIT_DYNAMIC_CALL                                        !6
         38        DO_FCALL                                      0  $32     
         39        ECHO                                                     $32
   26    40        FETCH_OBJ_R                                      ~33     !3, 'getEveningMessage'
         41        ASSIGN                                                   !7, ~33
   27    42        INIT_DYNAMIC_CALL                                        !7
         43        DO_FCALL                                      0  $35     
         44        ECHO                                                     $35
   28    45        INIT_USER_CALL                                0          'call_user_func', !7
         46        DO_FCALL                                      0  $36     
         47        ECHO                                                     $36
   29    48        INIT_METHOD_CALL                                         !7, '__invoke'
         49        DO_FCALL                                      0  $37     
         50        ECHO                                                     $37
   31    51        DECLARE_CLASS                                            'test', 'stdclass'
   37    52        NEW                                              $38     'Test'
         53        DO_FCALL                                      0          
         54        ASSIGN                                                   !8, $38
   38    55        ECHO                                                     !8
         56      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FBGjG0%3A6%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BGjG0
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, 'msg'
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

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

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

End of function %00%7Bclosure%7D%2Fin%2FBGjG0%3A14%241

Class Test:
Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BGjG0
function name:  __toString
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   FETCH_OBJ_R                                      ~0      'name'
          1        CAST                                          6  ~1      ~0
          2        VERIFY_RETURN_TYPE                                       ~1
          3      > RETURN                                                   ~1
   35     4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of function __tostring

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.08 ms | 1399 KiB | 13 Q