Richard Quadling <rquadl...@gmail.com> wrote:

> Hi.
> 
> Both
> 
> <?php
> class Oddity{
>   public $var = 'a' . 'b';
> }
> ?>
> 

>From http://www.php.net/manual/en/language.oop5.properties.php:

"This declaration may include an initialization, but this initialization
must be a constant value--that is, it must be able to be evaluated at
compile time and must not depend on run-time information in order to be
evaluated."


> and
> 
> <?php
> class Oddity{
> const A_VAR = 'a' . 'b';
> }
> ?>
> 
> produce ...
> 
> PHP Parse error:  syntax error, unexpected '.', expecting ',' or ';' in -
> on line 3

>From http://www.php.net/manual/en/language.oop5.constants.php: 

"The value must be a constant expression, not (for example) a variable,
a property, a result of a mathematical operation, or a function call."

> 
> For properties, has this always been the case?
> 
> Admittedly, this is the first time I've ever written code to assign a
> concatenated string to a static property ...
> 
>     static protected $s_NormaliserScript = __DIR__ . '/normalizedError.php';
> 
> And I was just surprised.
> 
> That's all.
> 
> Regards,
> 
> Richard.
> 
> P.S. Happy Friday!
> 
> 
> -- 
> Richard Quadling
> Twitter : @RQuadling
> EE : http://e-e.com/M_248814.html
> Zend : http://bit.ly/9O8vFY

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to