3v4l.org

run code in 300+ PHP versions simultaneously
<?php function calculateTotal(string $item, float $price, int $quantity = 1): string { $subtotal = $price * $quantity; return "$quantityx $item = $$subtotal"; } // Call the function and print the result echo calculateTotal($item, $price, $quantity);
Output for 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Warning: Undefined variable $item in /in/lP681 on line 10 Warning: Undefined variable $price in /in/lP681 on line 10 Warning: Undefined variable $quantity in /in/lP681 on line 10 Fatal error: Uncaught TypeError: calculateTotal(): Argument #1 ($item) must be of type string, null given, called in /in/lP681 on line 10 and defined in /in/lP681:3 Stack trace: #0 /in/lP681(10): calculateTotal(NULL, NULL, NULL) #1 {main} thrown in /in/lP681 on line 3
Process exited with code 255.

preferences:
43.03 ms | 479 KiB | 5 Q