3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { private $bar; public function __construct($bar) { $this->bar = $bar; } public function __toString() { return $bar; } } $a = new foo('abc'); $b = new foo('ab'); $pos = strpos($a,$b);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Warning: Undefined variable $bar in /in/tnoKs on line 9 Fatal error: Uncaught TypeError: foo::__toString(): Return value must be of type string, null returned in /in/tnoKs:9 Stack trace: #0 [internal function]: foo->__toString() #1 /in/tnoKs(15): strpos(Object(foo), Object(foo)) #2 {main} thrown in /in/tnoKs on line 9
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Warning: Undefined variable $bar in /in/tnoKs on line 9 Fatal error: Uncaught TypeError: foo::__toString(): Return value must be of type string, null returned in /in/tnoKs:9 Stack trace: #0 [internal function]: foo->__toString() #1 /in/tnoKs(15): strpos(Object(foo), Object(foo)) #2 {main} thrown in /in/tnoKs on line 9
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Notice: Undefined variable: bar in /in/tnoKs on line 9 Fatal error: Uncaught Error: Method foo::__toString() must return a string value in /in/tnoKs:15 Stack trace: #0 /in/tnoKs(15): strpos(Object(foo), Object(foo)) #1 {main} thrown in /in/tnoKs on line 15
Process exited with code 255.
Output for 7.3.32 - 7.3.33
Recoverable fatal error: Method foo::__toString() must return a string value in /in/tnoKs on line 15
Process exited with code 255.
Output for 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31
Notice: Undefined variable: bar in /in/tnoKs on line 9 Recoverable fatal error: Method foo::__toString() must return a string value in /in/tnoKs on line 15
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.38, 7.0.0 - 7.0.33
Notice: Undefined variable: bar in /in/tnoKs on line 9 Catchable fatal error: Method foo::__toString() must return a string value in /in/tnoKs on line 15
Process exited with code 255.

preferences:
234.07 ms | 402 KiB | 294 Q