i was following an ACL tut. which has used this piece of code.
class ACL
{
var $perms = array();
var $userID = 0;
var $userRoles = array();
function __constructor($userID = '')
{
}
}
however i am unable to understand some of the above declarations.
a) the class property is declared starting with var keyword in the above class, in data encapsulation is it not necessary we use public,private, or protected keywords before the declaration of the property.? is the above method meant for PHP4 ? or will it work for php5 too?
b) my IDE(Panic Coda). takes __construct as the correct syntax for constructor. the above code has used __constructor . which one is correct ? to my knowledge in PHP4 the constructor name should be the same as class name if that is the case then is __construct and __constructor one and the same in PHP5?
thank you
a) The
varkeyword is indeed probably meant for PHP 4 compatibility.varis equivalent with PHP 5’spublic. It will work in PHP 5 as well, but seeing as PHP 4’s time has passed, it is safe to move on topublic,private, andprotected.b)
__construct, or the name of the class for a PHP 4 compatible declaration, is the only correct way.__constructor()will not declare a constructor method.