Here is a scenario
class page {
public $name;
public $title;
public function showhead() {
return "<head><title>".$this->title."</title></head>";
}
}
$mypage = new page;
$mypage->title = "My Page title";
$mypage->showhead();
and another scenario
class page {
public $name;
public function showhead($title) {
return "<head><title>".$title."</title></head>";
}
}
$mypage = new page;
$mypage->showhead("My Page title");
Among these methods, which is better and which should be avoided? And why?