PHP

Too few arguments to function (PHP)

You called a function/method without all of its required parameters.

What it looks like

PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function sendMail(), 1 passed in /var/www/app/contact.php on line 40 and exactly 2 expected

What does "Too few arguments to function (PHP)" mean?

A fatal error (an ArgumentCountError) raised when a function or method is called with fewer arguments than it requires. The message gives both counts and the file and line of the call, so the bad call is easy to find.

What causes "Too few arguments to function (PHP)"?

  • A required argument wasn't passed.
  • A signature changed but a caller wasn't updated.
  • Wrong number of args after a refactor.

How do I confirm the cause?

  1. Go to the file and line named as the call site and compare the arguments with the function’s definition.
  2. If the function’s signature changed recently, search for every call to it — others may be broken too.
  3. For framework callbacks, check that the parameters the framework passes match what your function expects.

How do I fix "Too few arguments to function (PHP)"?

  • Pass all required arguments.
  • Give parameters default values if they're optional.
  • Check every caller after changing a signature.

How do I stop it happening again?

  • Give genuinely optional parameters default values, and use named arguments (PHP 8+) for long parameter lists.
  • Use static analysis (PHPStan, Psalm) to catch mismatched calls before they run.
Got a different error? Paste it into the Explain This Error tool → Identifies the family and the fix — runs locally, nothing uploaded.

Related errors