我折腾了两种在类中的方法中使用变量的方法。有些方法最多使用 20 个变量。哪个示例最能满足 OOP 编程结构以及原因
**Example 1:**
$sampleclass->variable1 = 100;
$sampleclass->variable2 = 200;
$sampleclass->variable3 = 300;
$row = $sampleclass->Method();
--------------------------
class sampleclass {
public function Method(){
if ($this->variable1) {
// do something
}
if ($this->variable2) {
// do something
}
if ($this->variable3) {
// do something
}
}
}
============================================
**Example 2:**
$row = $sampleclass->Method(100,200.300);
class sampleclass {
public function Method($variable1, $variable2, $variable3){
}
}