Unsupported operand types PHP Origin: Application & API Last updated 13 Oct 2026

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).

Exact message you may see Unsupported operand typesA non-numeric value encountered
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

  1. Cast and validate numbers: (float) $price
  2. Check variables are numbers before arithmetic
  3. Use array_sum() for arrays

Detailed fix by platform

PHP

  1. $total = array_sum(array_map('floatval', $prices));

How to diagnose

  1. Operands — What are the two types?
  2. 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:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

Array to string conversion — Warning: Array to string conversion (PHP)Array to string conve…Call to undefined function create_function() — WordPress on PHP 8: Fatal error: Uncaught Error: Call to undefined function create_function() / each() (WordPress)Call to undefined fun…Cannot convert value of type — Swift: Cannot convert value of type 'X' to expected argument type 'Y' (iOS)Cannot convert value …Cannot use object as array — Fatal error: Uncaught Error: Cannot use object of type stdClass as array (PHP)Cannot use object as …ClassCastException — java.lang.ClassCastException: class A cannot be cast to class B (Java)ClassCastExceptionDeprecated null to internal — Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated (PHP)Deprecated null to in…Dynamic property deprecated — Deprecated: Creation of dynamic property Foo::$bar is deprecated (PHP)Dynamic property depr…E0308 — Rust: error[E0308]: mismatched types — expected `X`, found `Y` (Rust)E0308Unsupport…

Explore the map of this error Full error map →

🧠 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.