I'm a procedural programmer who is dipping his feet into OOP for the first time. I have a question regarding member variables, take the following code for example (taken from a random web site):

Code PHP:
class test
{
	public $var;
	function Setvar()
	{
		$this->var = "test";
	}
	function Getvar()
	{
		return $this->var;
	}
}
 
$test = new test();
$test->Setvar();
echo $test->Getvar();

What is the point of the 'public $var;' when it's blank? I understand there must be a reason to set it like that, I just don't understand that reason.

From that example.. why would this be bad?

Code PHP:
class test
{
	function Setvar()
	{
		$this->var = "test";
	}
	function Getvar()
	{
		return $this->var;
	}
}
 
$test = new test();
$test->Setvar();
echo $test->Getvar();

Both examples work, so why set an empty variable at the top of the class? Is it just for "neatness"?