Unknown Named Parameter / Extra Arguments

Fatal error: Uncaught ArgumentCountError: Too many arguments to function trim(), 3 passed and at most 2 expected

Quick Answer

You are passing more arguments than the function accepts. Check the function signature and remove the extra arguments.

Why This Happens

Some PHP functions accept a fixed number of parameters. When you pass extra arguments, PHP throws an ArgumentCountError. This is common when confusing similar functions that take different numbers of parameters or when copy-pasting code with incorrect arguments.

The Problem

$cleaned = trim($input, ' ', '\n'); // trim only takes 2 arguments

The Fix

$cleaned = trim($input, " \n"); // Characters combined in one string

Step-by-Step Fix

  1. 1

    Check the function documentation

    Look up the function in the PHP manual to see its exact signature and how many parameters it accepts.

  2. 2

    Fix the argument list

    Remove extra arguments or combine them as the function expects. For trim(), multiple strip characters go in one string parameter.

  3. 3

    Use the right function

    If you need different behavior, you may need a different function. Check if there is a variant that accepts the arguments you want to pass.

Got the actual stack trace?

Paste it into our free AI explainer to get the cause and the fix for your specific case — no signup, nothing to install.

Explain my error

Bugsly catches this automatically

Bugsly's AI analyzes this error pattern in real-time, explains what went wrong in plain English, and suggests the exact fix — before your users even report it.

Try Bugsly free