I've been working with the Joomla framework and I have noticed that they use a convention to designate private or protected methods (they put an underscore "_
" in front of the method name), but they do not explicitly declare any methods public
, private
, or protected
. Why is this? Does it have to do with portability? Are the public
, private
, or protected
keywords not available in older versions of PHP?
views:
1349answers:
2
+12
A:
public, private and protected are PHP5 keywords. unfortunately, PHP4 still has a very high install base (especially amongst shared hosting services).
here's a pretty pic showing july usage rates (text in french). spoiler: php4 still has over a 35% usage rate sadly.
Owen
2008-10-13 04:46:06
PHP4 will generate an E_STRICT warning.
Darryl Hein
2008-10-13 04:48:30
E_STRICT was introduced in PHP5, unless i'm misunderstanding what you're saying
Owen
2008-10-13 04:55:00
The opposite was true for a while: the first few PHP 5 releases complained when "var" was used.
Ant P.
2008-12-02 01:17:37
+2
A:
PHP5 introduced some hefty changes in the object model. Among supporting visibility, there are various other changes. Be sure to check out:
ruquay
2008-10-13 20:31:25