JSEB
Newb
- Apr 2, 2020
- 13
- 14
I am fairly new to PHP, I am trying to get the total for a variable and a constant.
My variable is a random integer, and I need the total of $shirts bought, to match the price point I have set as my constant 'SHIRT_PRICE'
I hope I explained this well, the code I have currently:
The error I am getting: Fatal error: Uncaught TypeError: Unsupported operand types: int + string in C:\xampp\htdocs\clothing_sales.php:32 Stack trace: #0 {main} thrown in C:\xampp\htdocs\clothing_sales.php on line 32
My variable is a random integer, and I need the total of $shirts bought, to match the price point I have set as my constant 'SHIRT_PRICE'
I hope I explained this well, the code I have currently:
PHP:
<?php
define ('SHIRT_PRICE', '17.99');
$shirts = rand(1, 10);
echo $shirts_total = ($shirts += 'SHIRT_PRICE');
The error I am getting: Fatal error: Uncaught TypeError: Unsupported operand types: int + string in C:\xampp\htdocs\clothing_sales.php:32 Stack trace: #0 {main} thrown in C:\xampp\htdocs\clothing_sales.php on line 32