Function name must be a string

You can get an error like this Fatal error: Function name must be a string in foo.php on line 14 if you accidentally put a dollar sign at the beginning of a function name. You can also get the error if you are trying to use a non-string variable to hold the name of a function, or if you use round parens instead of square brackets when you are accessing an array.

WRONG

$this->$foo;

WRONG

$bar = 1234; $this->$bar;

WRONG $a = array(1, 2, 3); $b = $a(2);

RIGHT

$this->foo;

ALSO RIGHT

$bar = "foo"; $this->$bar;

ALSO RIGHT $a = array(1, 2, 3); $b = $a[2];