Re: Has this always been the case?
| From: | Stuart Dallas | Date: | Fri, 31 May 2013 11:07:01 +0000 |
| Subject: | Re: Has this always been the case? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-321291@lists.php.net to get a copy of this message | ||
On 31 May 2013, at 11:57, Richard Quadling <rquadling@gmail.com> wrote:
> Hi.
>
> Both
>
> <?php
> class Oddity{
> public $var = 'a' . 'b';
> }
> ?>
>
> and
>
> <?php
> class Oddity{
> const A_VAR = 'a' . 'b';
> }
> ?>
>
> produce ...
>
> PHP Parse error: syntax error, unexpected '.', expecting ',' or
> ';' in -
> on line 3
>
> 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.
Yes, it has. Initial values class constants and member variables must be literal values. If you need
to do that use a constructor.
-Stuart
--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/