Jump to content

"function __construct()" vs. "public function __construct()"


yoursurrogategod

Recommended Posts

The difference is that you are in control of the scope of the second decleration and not the first. You should always explicitly define the scope of your methods and variables rather than relying on the PHP systems defaults. If the default behaviour of PHP's scope definition changes in the future then the that will have an effect on anything you have not explicitly defined, and most likely break your classes.

 

As far as I remember PHP only allows for the omision of the scope deffinition (public, private or protected) purely for a legacy compatability. No new code should be writen without the use of one of them.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.