2010-11-24 7 views

Respuesta

5

Según the PHP docs:

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.

Trate de escribir

Config::$somevar = "Date: " . date('Y'); 

después de la definición de clase.

+1

¡Gracias, no lo sabía! –

1

De Manual

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.

2

Sin operación o función es permitir la inicialización de la propiedad, ya que este se evalúa al analizar.

Cuestiones relacionadas