PHP空构造函数 [英] PHP empty constructor

查看:81
本文介绍了PHP空构造函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是想知道是最好定义一个空的构造函数还是将构造函数定义完全留在PHP中?我习惯了只用 return true; 来定义构造函数,即使我不需要构造函数做任何事情-仅出于完成的原因。

Just wondering is it best to define an empty constructor or leave the constructor definition out completely in PHP? I have a habit of defining constructors with just return true;, even if I don't need the constructor to do anything - just for completion reasons.

推荐答案

如果不需要构造函数,则最好将其省略,无需编写更多代码。当您确实编写它时,请将其留为空白...返回true没有目的。

If you don't need a constructor it's best to leave it out, no need to write more code. When you DO write it, leave it empty... returning true doesn't have a purpose.

这篇关于PHP空构造函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆