Difference between declaring a variable as "var $ foo" or "$ foo" in PHP?

The name explains all this. Who cares?

var $foo;
$bar;

What is the main difference between these two variables?

I noticed that "var $ foo" is mainly used to declare class attributes, but why is this?

Thanks for all your answers.

+5
source share
1 answer

In PHP 4 it is varused to define variables in classes. In PHP 5, it is deprecated and you should use public, privateor instead protected. Outside of classes, it should have no effect (although you might get a warning in PHP 5).

+16
source

All Articles