The PHP 4 method of declaring a variable, using the
var keyword, was deprecated in early versions of PHP 5. Even though it’s not
considered deprecated in the most recent versions, it’s nonetheless not best practice to use it. When
var does appear, it is interpreted
as a synonym for
public and treated as such. Therefore
public should be used instead.
From the PHP Manual:
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.
Noncompliant Code Example
var $bar = 1;
public $bar = 1;