这里是一个情景在OOP中应尽可能避免使用方法中的参数?
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();
和另一个场景
class page {
public $name;
public function showhead($title) {
return "<head><title>".$title."</title></head>";
}
}
$mypage = new page;
$mypage->showhead("My Page title");
在这些方法中,哪一个更好,并且应该避免?为什么?
错字? “尽可能地避免并尽量使用” - 改变和或? – apollodude217 2010-07-06 21:49:34