为什么不在PHP中使用“保护”或“私有”?

问题描述:

我一直在使用Joomla框架,并且我注意到它们使用约定来指定私有或受保护的方法(它们前面加了下划线 _ 方法名称),但它们未明确声明任何方法 public private 受保护的。为什么是这样?它与可移植性有关吗? 公共私有受保护的关键字不可用在旧版本的PHP中?

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?

公开,私有和受保护是PHP5关键字。不幸的是,PHP4的安装量仍然很高(尤其是在共享托管服务中)。

public, private and protected are PHP5 keywords. unfortunately, PHP4 still has a very high install base (especially amongst shared hosting services).

这是漂亮的图片显示了7月的使用率(法文)。 剧透:可悲的是,php4的使用率仍然超过35%。

here's a pretty pic showing july usage rates (text in french). spoiler: php4 still has over a 35% usage rate sadly.