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).
Unsupported operand typesA non-numeric value encountered 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 not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Array to string conversion Warning: Array to string conversion
- Call to undefined function create_function() WordPress on PHP 8: Fatal error: Uncaught Error: Call to undefined function create_function() / each()
- Cannot convert value of type Swift: Cannot convert value of type 'X' to expected argument type 'Y'
Most viewed in PHP
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 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.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 13 Oct 2026