Skip to main content
2 of 3
added 75 characters in body
Mike Barwick
  • 5.4k
  • 7
  • 56
  • 78

Setting private variable on class

I'm trying to set a private variable array on my class. But I'm getting an error. Is this even possible? In other words, can I define a variable with a key - or is it bad practice?

class SomeClass { private $result['results'] = array(); .... 

Error: Parse error: syntax error, unexpected '[', expecting ',' or ';'

Mike Barwick
  • 5.4k
  • 7
  • 56
  • 78