2013/5/28 Amaury Bouchard <ama...@amaury.net>

> 2013/5/28 Maciek Sokolewicz <maciek.sokolew...@gmail.com>
>
> > It’s a good idea in general but what about having it for variables as
> >> well? Could open interesting possibilities for an optimizer.
> >>
> >> final $foo = "str";
> >> $foo = "bar"; // bails out
> >>
> >>  Don't we already have that? It just has a different name: constants.
>
>
> It's different. You can manipulate variables in some ways you can't with
> constants.
>
> This code, for example:
>    $a = 'abc';
>    $b = 'a';
>    print($$b);
>
> It will display "abc". It's currently not possible to do something similar
> with constants.
>

define('FOO', 'bar');
$b = 'FOO';
print(constant($b));

and yes, constant() works for namespace- and class-constants too.


>
> I think the subject was already debated, but I wonder why we should write
> that:
>    final $foo = 'bar';
> instead of:
>    const $foo = 'bar';
>



-- 
github.com/KingCrunch

Reply via email to