syntax error, unexpected ‘)’, expecting variable (T_VARIABLE)

Description

This error is related to the support the trailing comma in function calls: in PHP 7.4, it is allowed to add a final comma at the end of the arguments list, and yet, not provide an extra argument.

Example

<?php

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

echo foo(1,
         2,
         3,
         );

?>

Solutions

  • Upgrade to PHP 7.4.

  • Remove the trailing comma.