1

I am currently trying to use the https://github.com/muesli/huephp to control my lights through PHP but I am running into a syntax problem.

Here is the line in huecli.php that I am getting a syntax error on where [... Here is the actual error: "Parse error: syntax error, unexpected '[' "

$hue->lights()[$light]->setLight( $command );

There are more errors but it seems the [$light] is causing the problem. I haven't worked with this kind of syntax before so any help is appreciated!

dlamblin
  • 43,965
  • 20
  • 101
  • 140

1 Answers1

3

You are probably not running PHP 5.4+ which is what is required to use Array Dereferencing. To use this code it must be modified as so:

$hue_lights = $hue->lights();
$hue_lights[$light]->setLight( $command );
John Conde
  • 217,595
  • 99
  • 455
  • 496