%d arguments are required, %d given¶
Description¶
The actual number of arguments of the function is commanded by the first argument: there must be an extra argument for every %s
in that argument. In the illustration code, there are 4 expected arguments, on top of the first one, and only 2 arguments, including the first one.
This error message is related to the PHP native functions printf()
, vprintf()
, sprintf()
, fprintf()
, vfprintf()
.
Example¶
<?php
// count() has one or two arguments
count($array, $recursive, $tooMany);
// printf()'s number of arguments depends on the first one
printf('%s %s %s %s', $variable);
?>
Literal Examples¶
4 arguments are required, 2 given
Solutions¶
Reduce the number of %s in the first argument.
Add the missing argument in the function call.
Replace the %s by %%s.
In previous PHP versions, this error message used to be Too few arguments.