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

Trailing Comma In Arguments

Trailing comma in arguments is the last argument left empty. This last argument is not transmitted, so the last comma has no effect. This feature is useful when arguments are kept on a different line : the last argument has now also a comma, and adding one extra argument will yield a one line diff, compared to the previous version. Without it, the diff would be two lines, and include the preceding line.

PHP code

<?php

function foo($a,
             $b,
             $c,
              ) { echo __METHOD__; }

echo foo(1);

?>

Before

PHP Parse error:  syntax error, unexpected ')', expecting variable (T_VARIABLE)

After

foo

PHP version change

This behavior changed in 8.0.

Error Messages

Extension

Analyzer

© 2023-2026, Damien Seguy - Exakat