1

While doing a data transfer object I need to define properties in my class. Some of them have strange names like 'foo-bar' or 'name with spaces'.

I know you can access and assign properties like this with syntax $a->{'bad key'} = 123. But can something similar be used when defining class properties?

class Data
{
    public $foo-bar; // obviously wont work
    public ${'foo-bar'}; // wont work
}

Any remedy for my situation?

ajthinking
  • 4,120
  • 5
  • 36
  • 67

0 Answers0