Welcome Guest, Not a member yet? Register   Sign In
Another 'best practice' question about controllers (and PHP classes in general)
#2

[eluser]jrtashjian[/eluser]
Good practice in php when defining variable visibility in a class is to make all vars private or protected. Relax restrictions only as needed. Differences between property visibility:

Public properties can be accessed from anywhere.
Private properties can only be accessed from within the enclosing class. Subclasses have no access.
Protected properties can only be accessed from within the enclosing class and from a subclass.

Yes it's better to define those variables at the top of the controller. Bad practice would be repeating yourself. I do something similar to what you've posted. I'd say you're on the right track.


Messages In This Thread
Another 'best practice' question about controllers (and PHP classes in general) - by El Forum - 10-06-2010, 05:28 AM



Theme © iAndrew 2016 - Forum software by © MyBB