3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait mytrait { public function foo() { return get_class($this); } } class myclass { use mytrait; } var_dump((new myclass)->foo()); $obj = new myclass; $obj->bar = 'foo'; var_dump($obj->bar);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FKoZR
function name:  (null)
number of ops:  18
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   DECLARE_CLASS                                            'myclass'
   16     1        INIT_FCALL                                               'var_dump'
          2        NEW                                              $1      'myclass'
          3        DO_FCALL                                      0          
          4        INIT_METHOD_CALL                                         $1, 'foo'
          5        DO_FCALL                                      0  $3      
          6        SEND_VAR                                                 $3
          7        DO_ICALL                                                 
   18     8        NEW                                              $5      'myclass'
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !0, $5
   19    11        ASSIGN_OBJ                                               !0, 'bar'
         12        OP_DATA                                                  'foo'
   21    13        INIT_FCALL                                               'var_dump'
         14        FETCH_OBJ_R                                      ~9      !0, 'bar'
         15        SEND_VAL                                                 ~9
         16        DO_ICALL                                                 
         17      > RETURN                                                   1

Class mytrait:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FKoZR
function name:  foo
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   FETCH_THIS                                       ~0      
          1        GET_CLASS                                        ~1      ~0
          2      > RETURN                                                   ~1
    7     3*     > RETURN                                                   null

End of function foo

End of class mytrait.

Class myclass: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.43 ms | 1395 KiB | 15 Q