public 和 not function 之间的区别
之间有什么不同
public function something()
{
}
和
function something()
{
}
任何解释吗?哪个更好?
what is the different between
public function something()
{
}
and
function something()
{
}
any explaination? which more better?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
PHP/4 尚未实现可见性。当它被添加到 PHP/5 中时,缺失的可见性关键字将成为
public
的同义词,因此现有代码不会被破坏。如果它是遗留代码,我的建议是保持原样,直到您有机会检查代码并选择足够的可见性。如果它是新代码,您应该将其明确化。
PHP/4 did not implement visibility yet. When it was added in PHP/5, a missing visibility keyword was made synonym of
public
so existing code would not break.If it's legacy code, my advice is to leave it as is until you have the chance to review the code and pick an adequate visibility. If it's new code, you should make it explicit.