3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Testing { private $value = 0; public function incrementBy1() { $this->value ++; if (rand(1, 9)) { return null; } return $this; } public function output() { echo "value: " . $this->value; } } $test = new Testing; $test->incrementBy1()->incrementBy1()->incrementBy1()->output();
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.26, 7.3.0 - 7.3.13, 7.4.0 - 7.4.1
Fatal error: Uncaught Error: Call to a member function incrementBy1() on null in /in/NiZoZ:23 Stack trace: #0 {main} thrown in /in/NiZoZ on line 23
Process exited with code 255.
Output for 5.6.0 - 5.6.40
Fatal error: Call to a member function incrementBy1() on null in /in/NiZoZ on line 23
Process exited with code 255.

preferences:
140.34 ms | 401 KiB | 157 Q