3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function getBar($obj) { var_dump($obj->bar); } public function getBaz($obj) { var_dump($obj->baz); } public function getVars($obj) { var_dump(get_object_vars($obj)); } } $obj = (object) array( "\0*\0bar" => 1, "\0Foo\0baz" => 2, ); // trying `get_object_vars` from global scope var_dump(get_object_vars($obj)); // trying from Foo instance (new Foo())->getVars($obj); // trying from a Foo instance (new Foo())->getBar($obj); (new Foo())->getBaz($obj); // trying from a closure bound to `stdClass` var_dump(Closure::bind(function ($obj) { var_dump($obj->bar, $obj->baz); }, $obj, 'stdClass')->__invoke($obj)); // trying from a closure bound to `Foo` var_dump(Closure::bind(function ($obj) { var_dump($obj->bar, $obj->baz); }, $obj, 'Foo')->__invoke($obj)); // direct access (causes fatal) var_dump($obj->{"\0*\0bar"}); var_dump($obj->{"\0Foo*\0baz"});
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UtlEg
function name:  (null)
number of ops:  56
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   CAST                                          8  ~1      <array>
   21     1        ASSIGN                                                   !0, ~1
   27     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'get_object_vars'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $3      
          6        SEND_VAR                                                 $3
          7        DO_ICALL                                                 
   30     8        NEW                                              $5      'Foo'
          9        DO_FCALL                                      0          
         10        INIT_METHOD_CALL                                         $5, 'getVars'
         11        SEND_VAR_EX                                              !0
         12        DO_FCALL                                      0          
   33    13        NEW                                              $8      'Foo'
         14        DO_FCALL                                      0          
         15        INIT_METHOD_CALL                                         $8, 'getBar'
         16        SEND_VAR_EX                                              !0
         17        DO_FCALL                                      0          
   34    18        NEW                                              $11     'Foo'
         19        DO_FCALL                                      0          
         20        INIT_METHOD_CALL                                         $11, 'getBaz'
         21        SEND_VAR_EX                                              !0
         22        DO_FCALL                                      0          
   37    23        INIT_FCALL                                               'var_dump'
         24        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
         25        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FUtlEg%3A37%240'
         26        SEND_VAL                                                 ~14
         27        SEND_VAR                                                 !0
         28        SEND_VAL                                                 'stdClass'
         29        DO_FCALL                                      0  $15     
         30        INIT_METHOD_CALL                                         $15, '__invoke'
         31        SEND_VAR_EX                                              !0
         32        DO_FCALL                                      0  $16     
         33        SEND_VAR                                                 $16
         34        DO_ICALL                                                 
   40    35        INIT_FCALL                                               'var_dump'
         36        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
         37        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FUtlEg%3A40%241'
         38        SEND_VAL                                                 ~18
         39        SEND_VAR                                                 !0
         40        SEND_VAL                                                 'Foo'
         41        DO_FCALL                                      0  $19     
         42        INIT_METHOD_CALL                                         $19, '__invoke'
         43        SEND_VAR_EX                                              !0
         44        DO_FCALL                                      0  $20     
         45        SEND_VAR                                                 $20
         46        DO_ICALL                                                 
   43    47        INIT_FCALL                                               'var_dump'
         48        FETCH_OBJ_R                                      ~22     !0, '%00%2A%00bar'
         49        SEND_VAL                                                 ~22
         50        DO_ICALL                                                 
   44    51        INIT_FCALL                                               'var_dump'
         52        FETCH_OBJ_R                                      ~24     !0, '%00Foo%2A%00baz'
         53        SEND_VAL                                                 ~24
         54        DO_ICALL                                                 
         55      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FUtlEg%3A37%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UtlEg
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'var_dump'
          2        FETCH_OBJ_R                                      ~1      !0, 'bar'
          3        SEND_VAL                                                 ~1
          4        FETCH_OBJ_R                                      ~2      !0, 'baz'
          5        SEND_VAL                                                 ~2
          6        DO_ICALL                                                 
          7      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FUtlEg%3A37%240

Function %00%7Bclosure%7D%2Fin%2FUtlEg%3A40%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UtlEg
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'var_dump'
          2        FETCH_OBJ_R                                      ~1      !0, 'bar'
          3        SEND_VAL                                                 ~1
          4        FETCH_OBJ_R                                      ~2      !0, 'baz'
          5        SEND_VAL                                                 ~2
          6        DO_ICALL                                                 
          7      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FUtlEg%3A40%241

Class Foo:
Function getbar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UtlEg
function name:  getBar
number of ops:  6
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        INIT_FCALL                                               'var_dump'
          2        FETCH_OBJ_R                                      ~1      !0, 'bar'
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                                 
    8     5      > RETURN                                                   null

End of function getbar

Function getbaz:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UtlEg
function name:  getBaz
number of ops:  6
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   12     1        INIT_FCALL                                               'var_dump'
          2        FETCH_OBJ_R                                      ~1      !0, 'baz'
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                                 
   13     5      > RETURN                                                   null

End of function getbaz

Function getvars:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UtlEg
function name:  getVars
number of ops:  8
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   17     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'get_object_vars'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $1      
          5        SEND_VAR                                                 $1
          6        DO_ICALL                                                 
   18     7      > RETURN                                                   null

End of function getvars

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.52 ms | 1404 KiB | 17 Q