-1

I am trying to create a static property with a DOMDocument. However, I am getting the following error:

syntax error, unexpected 'new' (T_NEW)

Here's the declaration:

protected static $domd = new DOMDocument();

What am I doing wrong?

Maeh
  • 1,774
  • 4
  • 18
  • 31

1 Answers1

0

"Like any other PHP static variable, static properties may only be initialized using a literal or constant; expressions are not allowed. So while you may initialize a static property to an integer or array (for instance), you may not initialize it to another variable, to a function return value, or to an object."

You cannot assign a new instance of a class to a static property.

See manual for details

boomx09
  • 13
  • 4