tags:

views:

356

answers:

1

The title explains it all. What's the difference?

var $foo;
$bar;

What's the main difference between this two variables?

I've noticed that "var $foo" is mostly used to declare class attributes, but why is it so?

Thanks in advance for all your answers.

+12  A: 

In PHP 4 var is used to define variables in classes. In PHP 5 it is deprecated, and you must use public, private, or protected instead. Outside of classes it shouldn't have any effect (although you might get a warning in PHP 5).

yjerem