3v4l.org

run code in 500+ PHP versions simultaneously
<?php class stringable1 { function __toString() { return "abc"; } } $s = new stringable1(); // AS EXPECTED: converts the object into a string executes the replace in the same fashion with a plain php string var_dump(str_replace('a', 'x', $s)); var_dump(strpos('abcd', $s)); var_dump(stripos('abcd', $s));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7X8QE
function name:  (null)
number of ops:  21
compiled vars:  !0 = $s
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                                'stringable1'
    9     1        NEW                                                  $1      'stringable1'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $1
   12     4        INIT_FCALL                                                   'var_dump'
          5        FRAMELESS_ICALL_3                str_replace         ~4      'a', 'x'
          6        OP_DATA                                                      !0
          7        SEND_VAL                                                     ~4
          8        DO_ICALL                                                     
   14     9        INIT_FCALL                                                   'var_dump'
         10        FRAMELESS_ICALL_2                strpos              ~6      'abcd', !0
         11        SEND_VAL                                                     ~6
         12        DO_ICALL                                                     
   15    13        INIT_FCALL                                                   'var_dump'
         14        INIT_FCALL                                                   'stripos'
         15        SEND_VAL                                                     'abcd'
         16        SEND_VAR                                                     !0
         17        DO_ICALL                                             $8      
         18        SEND_VAR                                                     $8
         19        DO_ICALL                                                     
         20      > RETURN                                                       1

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

End of function __tostring

End of class stringable1.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
215.76 ms | 2177 KiB | 15 Q