Fatal error: Uncaught TypeError: Unsupported operand types: string + int
An arithmetic or array operator was used with incompatible types (PHP 8 is stricter than PHP 7).
Seen on:
PHP
Meaning
PHP 8 throws for operations like array + int or string + array. Non-numeric strings in arithmetic throw “Unsupported operand types” or warn “A non-numeric value encountered”.
Common causes
- Array used in arithmetic
- null/empty array where a number was expected
- Non-numeric strings from input
⚡ Quick fix
- Cast and validate numbers:
(float) $price - Check variables are numbers before arithmetic
- Use array_sum() for arrays
Detailed fix by platform
PHP
$total = array_sum(array_map('floatval', $prices));
How to diagnose
- Operands — What are the two types?
- Source — Where does the non-number come from?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026