Syntax error for index within string (allowed only ID, variable or number)

Sample code:

$str = "$x[$c->x]";             // Syntax error for index within string (allowed only ID, variable or number)

PHP allows only ID, variable or number constant to be used as index for array when used within string.