syntax error, unexpected token “,”, expecting variable or “$”¶
Description¶
This error is reported when a list of global variable is expected after the global
keyword.
There is a similar case with the visibility options public
, protected
and private
, and the static
keyword, although global
is the only keyword with accepts variable variables.
Generally speaking, there can be no two successive commas in an expression, except with the list()
keyword.
Example¶
<?php
class X {
public function foo() {
global $a, , $c;
}
}
?>
Solutions¶
Remove the extra comma.
Fill the empty slot with a variable.