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 Calls

Trailing commas in parameters is the last parameter left empty. This last parameter is not transmitted, so the last comma has no effect. This feature is useful when parameters 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,
         2,
         3,
         );

?>

Before

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

After

foo

PHP version change

This behavior changed in 7.3.

Error Messages

Extension

Analyzer

© 2023-2026, Damien Seguy - Exakat