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?
I guess it depends on whether you need that title ever again. if you do then make property for storage and retrieval. if you only need it that one time then use the method parameter.