3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { function __toString() { return "blahxblah"; } } $foo = new foo; var_dump(strpos($foo, "x")); var_dump(strpos("x", $foo));
Output for 7.3.32 - 7.3.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
int(4) bool(false)
Output for 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
int(4) Notice: Object of class foo could not be converted to int in /in/sjtsH on line 10 Deprecated: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in /in/sjtsH on line 10 bool(false)
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.38, 7.0.0 - 7.0.31, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33
int(4) Notice: Object of class foo could not be converted to int in /in/sjtsH on line 10 bool(false)

preferences:
245.36 ms | 403 KiB | 337 Q