3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Primary { public function __toString() { $GLOBALS['anObject'] = $this; return 'toString output from Primary'; } } $Foo = new Primary; str_replace('', '', $Foo); var_dump($GLOBALS['anObject']); // expected to be object of class Primary, actually string
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GoI4V
function name:  (null)
number of ops:  15
compiled vars:  !0 = $Foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   DECLARE_CLASS                                            'primary'
    8     1        NEW                                              $1      'Primary'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
    9     4        INIT_FCALL                                               'str_replace'
          5        SEND_VAL                                                 ''
          6        SEND_VAL                                                 ''
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                                 
   10     9        INIT_FCALL                                               'var_dump'
         10        FETCH_R                      global              ~5      'GLOBALS'
         11        FETCH_DIM_R                                      ~6      ~5, 'anObject'
         12        SEND_VAL                                                 ~6
         13        DO_ICALL                                                 
   11    14      > RETURN                                                   1

Class Primary:
Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GoI4V
function name:  __toString
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   FETCH_THIS                                       ~2      
          1        FETCH_W                      global              $0      'GLOBALS'
          2        ASSIGN_DIM                                               $0, 'anObject'
          3        OP_DATA                                                  ~2
    5     4      > RETURN                                                   'toString+output+from+Primary'
    6     5*       VERIFY_RETURN_TYPE                                       
          6*     > RETURN                                                   null

End of function __tostring

End of class Primary.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.41 ms | 1395 KiB | 17 Q