[英]Why would this line of code be executed if the IF condition is false? Doesn't make any sense
這是代碼:
<?php
class Order extends Zend_Db_Table_Abstract
{
protected $_name = 'orders';
protected $_limit = 200;
protected $_authorised = false;
public function setLimit($limit)
{
$this->_limit = $limit;
}
public function setAuthorised($auth)
{
$this->_authorised = (bool) $auth;
}
public function insert(array $data)
{
if ($data['amount'] > $this->_limit && $this->_authorised === false) {
throw new Exception('Unauthorised transaction of greater than ' . this->_limit . ' units');
}
return parent::insert($data);
}
}
如果條件失敗,為什么只運行該方法。 我是C#程序員,我的邏輯表明無論IF如何它都會運行,對嗎? 太感謝了。
異常將中斷代碼執行。
即使在C#中,即使拋出異常,也不會執行代碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.