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?
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?
"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