3v4l.org

run code in 300+ 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));

preferences:
56.5 ms | 402 KiB | 5 Q