<?php
class foo {
final public $bar = 10;
}
$f = new foo;
$a = 'bar';
$f->$a = 20;
echo $f->bar;
?>
outputs :
20
Final needs to be runtime.
-Sterling
PS: Insert mention of how this feature doesn't belong in a language like php here. Also mention that interfaces/abstract suffer from the same problem, and should be removed for the same reason.
--
"People can have the Model T in any colour -- so long as it's black." - Henry Ford
Sterling Hughes wrote:
Quoted text · 11 lines
<?php
class foo {
final public $bar = 10;
}$f = new foo;
$a = 'bar';
$f->$a = 20;
echo $f->bar;
?>
[b0rk3d output snipped]PS: Insert mention of how this feature doesn't belong in a language like php here. Also mention that interfaces/abstract suffer from the same problem, and should be removed for the same reason.
+1 for removing all that stuff. :P
Best Regards
Mike Robinson
At 20:51 18.04.2003, Mike Robinson wrote:
Quoted text · 6 lines
Sterling Hughes wrote:
<?php
class foo {
final public $bar = 10;
}[b0rk3d output snipped]
I don't see a reason or sense in "final" for properties. IMO it is only in there by
mistake.
PS: Insert mention of how this feature doesn't belong in a language like php here. Also mention that interfaces/abstract suffer from the same problem, and should be removed for the same reason.
+1 for removing all that stuff. :P
Final and interfaces are ways to express aspects of an oo model. When working in big projects you'll get used to such. If not feel free to ignore the feature just like any other feature you dislike in php, too.
regards
marcus