3v4l.org

run code in 300+ PHP versions simultaneously
<?php class stringable { function __toString() { return "abc"; } } $s = new stringable(); // 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/Bf3Ah
function name:  (null)
number of ops:  27
compiled vars:  !0 = $s
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'stringable'
    9     1        NEW                                              $1      'stringable'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   12     4        INIT_FCALL                                               'var_dump'
          5        INIT_FCALL                                               'str_replace'
          6        SEND_VAL                                                 'a'
          7        SEND_VAL                                                 'x'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $4      
         10        SEND_VAR                                                 $4
         11        DO_ICALL                                                 
   14    12        INIT_FCALL                                               'var_dump'
         13        INIT_FCALL                                               'strpos'
         14        SEND_VAL                                                 'abcd'
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                         $6      
         17        SEND_VAR                                                 $6
         18        DO_ICALL                                                 
   15    19        INIT_FCALL                                               'var_dump'
         20        INIT_FCALL                                               'stripos'
         21        SEND_VAL                                                 'abcd'
         22        SEND_VAR                                                 !0
         23        DO_ICALL                                         $8      
         24        SEND_VAR                                                 $8
         25        DO_ICALL                                                 
         26      > RETURN                                                   1

Class stringable:
Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Bf3Ah
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 stringable.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.3 ms | 1396 KiB | 21 Q