From: http://stackoverflow.com/questions/1206105/what-does-php-keyword-var-do
這是用在 php4 的類別成員變數的宣告,也適用於 php5 。但因為 php5 配置較為嚴僅(E_STRICT)的關係 冠上 var 會被提出警告。
It’s for declaring class member variables in PHP4, and is no longer needed. It will work in PHP5, but will raise an E_STRICT warning in PHP from version 5.0.0 up to version 5.1.2, as of which it has been deprecated.
Example usage:
class foo {
var $x = ‘y’; // or you can use public like…
public $x = ‘y’; //this is also a class member variables.
function bar() {}
}
var keyword 是在 PHP4 中宣告類別成員變數用的,而在 PHP5 中則改用 public、protext、private, 當然還是可以使用var宣告成員變數,但是不建議這樣做。
The var keyword is used to declare variables in a class in PHP 4:
class Foo {
var $bar;
}
With PHP 5 property and method visibility (public, protected and private) was introduced and thus var is deprecated.