这是非常多余的,我只想对请求的任何部分以及正在选择的多个部分的任何变化说一次“OK TO SEND”。
if ($this->part1) return "OK TO SEND: $this->part1 ";
if ($this->part2) return "OK TO SEND: $this->part2 ";
if ($this->part3) return "OK TO SEND: $this->part3 ";
if ($this->part4) return "OK TO SEND: $this->part4 ";
if ($this->part5) return "OK TO SEND: $this->part5 ";
if ($this->part6) return "OK TO SEND: $this->part6 ";
if ($this->part7) return "OK TO SEND: $this->part7 ";
我不确定我是否只使用 if 和 ifelse 语句或循环。我确信循环将是最有效的。任何帮助将不胜感激。
像这样的东西?
$params = array($this->part1, $this->part2, $this->part3, $this->part4, $this->part5, $this->part6, $this->part7) ;
我会使用 in_array 函数吗?