Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

ArgumentCountError

ArgumentCountError is thrown when too few arguments are passed to a user-defined or PHP native function or method. This is an error, not an exception.

No exception is raised for extra parameters, as those may still be processed by the method itself.

<?php

    function trumpet($a) {}

    // No error is raised here
    trumpet(1,2);

    // ArgumentCountError is catchable
    try {
        trumpet();
    } catch (ArgumentCountError) {
        print 'No enough parameters passed.';
    }

?>

Documentation

See Also