3v4l.org

run code in 300+ PHP versions simultaneously
<?php class 🍏 {} class 🍉 {} class 🍍 {} class 🍌 {} class 🥗 { protected $🎁🎁 = []; public function add($🎁) { $this->🎁🎁[] = $🎁; } public function __toString() { $🎁2 = []; foreach($this->🎁🎁 as $🎁){ $🎁2[get_class($🎁)] = ($🎁2 ?? 0) + 1; } foreach($🎁2 as $🎁3 => $🎁4){ $🎁2[$🎁3] = $🎁4 . ' ' . $🎁3; } echo implode(', ', $🎁2); } } $🥗 = new 🥗(); $🥗->add(new 🍏()); $🥗->add(new 🍉()); $🥗->add(new 🍍()); $🥗->add(new 🍉()); $🥗->add(new 🍉()); $🥗->add(new 🍏()); $🥗->add(new 🍉()); $🥗->add(new 🍏()); echo $🥗;
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Fatal error: Uncaught TypeError: Unsupported operand types: array + int in /in/7UGKL:21 Stack trace: #0 /in/7UGKL(43): 🥗->__toString() #1 {main} thrown in /in/7UGKL on line 21
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Fatal error: Uncaught Error: Unsupported operand types in /in/7UGKL:21 Stack trace: #0 /in/7UGKL(43): 🥗->__toString() #1 {main} thrown in /in/7UGKL on line 21
Process exited with code 255.
Output for 7.0.1 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
Fatal error: Method 🥗::__toString() must not throw an exception, caught Error: Unsupported operand types in /in/7UGKL on line 0
Process exited with code 255.
Output for 7.0.0
Fatal error: Method 🥗::__toString() must not throw an exception in /in/7UGKL on line 0
Process exited with code 255.
Output for 5.6.0 - 5.6.40
Parse error: syntax error, unexpected '?' in /in/7UGKL on line 21
Process exited with code 255.

preferences:
216.39 ms | 401 KiB | 287 Q