php - Do public static final class variables exist -
in jave can define public static final variable in class. there equivalent in php?
i'd following:
<?php class myclass{ public final static $finalvariable = "something"; } myclass::$finalvariable and not ever have worry $finalvariable changing , not having new instance every instantiation of myclass
from this page in php manual:
note: properties cannot declared final, classes , methods may declared final.
however, can use class constants described here.
your example this:
<?php class myclass{ const finalvariable = "something"; } myclass::finalvariable; ?> except of course finalvariable isn't appropriate name because it's not variable =).
Comments
Post a Comment