Do you always add public beside methods and properties inside your classes? Or do you leave it out?
1. Option 1, without public:
<?php
class SimpleClass {
// property declaration
$var = 'a default value';
// method declaration
function displayVar() {
echo $this->var;
}
}
?>
2. Option 2, with public:
<?php
class SimpleClass {
// property declaration
public $var = 'a default value';
// method declaration
public function displayVar() {
echo $this->var;
}
}
?>
Personally I think adding public adds a little more clarity to the code, though what is considered best practice?