PHP class: Global variable vs Accessbale varibales
This question already has an answer here:
The keyword before variable name defines the visibility of the variable. It defines the access rights for the particular variable.
var
When using var , it will be publicly accessible through out your project same as public .
protected
When using protected , variable is only accessible for the classes which extends parent class for particular page only.
Note: The PHP 4 method of declaring a variable with the var keyword is still supported for compatibility reasons (as a synonym for the public keyword). In PHP 5 before 5.1.3, its usage would generate an E_STRICT warning.
Read More Here
链接地址: http://www.djcxy.com/p/96552.html