Deprecated null to internal 🐘 PHP

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated

PHP 8.1+ warns when null is passed to a built-in function that expects a string/int.

Seen on: PHP

Meaning

Internal functions used to coerce null silently. PHP 8.1 deprecates it (and a future version will throw). The value is usually an optional input or missing database field.

Common causes

  • Optional request field passed directly to string functions
  • Nullable DB column
  • Return value of a function that can be null

⚡ Quick fix

  1. Coalesce: strlen($name ?? '')
  2. Validate inputs early
  3. Fix the source of the null

Detailed fix by platform

PHP

  1. Search logs for "Passing null to parameter" to find every call site after upgrading

How to diagnose

  1. Function — Which function and parameter?
  2. Value — Why is it null?

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