3v4l.org

run code in 300+ PHP versions simultaneously
<?php class LuckyNumbers { public function sumUp(array $digitsOfNumber1, array $digitsOfNumber2): int { $convNum1 = (int) implode($digitsOfNumber1); $convNum2 = (int) implode($digitsOfNumber2); return $convNum1+ $convNum2; throw new \BadFunctionCallException("Implement the function"); } public function isPalindrome(int $number): bool { // Reversing steps:- $numberString = (string) $number; $reverseNumberString = strrev($numberString); $reverseNumber = (int) $reverseNumberString; return $number == $reverseNumber; throw new \BadFunctionCallException("Implement the function"); } public function validate(string $input): string { if ($input <= 0) { echo "Must be a whole number larger than 0"; } if ($input == '') { echo "Required field"; } } } $lucky_numbers = new LuckyNumbers(); $lucky_numbers->validate('123');
Output for 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
Fatal error: Uncaught TypeError: LuckyNumbers::validate(): Return value must be of type string, none returned in /in/sa7qN:36 Stack trace: #0 /in/sa7qN(40): LuckyNumbers->validate('123') #1 {main} thrown in /in/sa7qN on line 36
Process exited with code 255.

preferences:
42.59 ms | 406 KiB | 5 Q