阅读背景:

从函数返回“错误”的最佳实践

来源:互联网 

I have a function:

我有一个功能:

public function CustomerRating() {
     $result = $db->query("...");
     $row = $result->fetch_assoc();

     if($row)
          $output = $row['somefield'];
     } else {
          $output = "error";
     }

     return $output;
}

//somewhere on another page...
if(is_numeric($class->CustomerRating()) {
     echo $class->CustomerRating;
} else {
      echo "There is an error with this rating.";
}
public function 



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: