Why should I fix E_NOTICE errors? Pros and cons

Should I use E_NOTICE for the active server?

How can I see in Why should I fix E_NOTICE errors? all again use isset()to skip notifications. I read the pros, but what about code readability?

Let's look at some code:

if ($this->_oldattributes['category_id'] != $tattr['category_id']
    || $this->_oldattributes['deal_id'] != $tattr['deal_id']
) {

Clear to understand what I want here, right?

Let's add isset()to omit notifications:

$old_cat_id = isset($this->_oldattributes['category_id']) ? $this->_oldattributes['category_id'] : null;
$new_cat_id = isset($tattr['category_id']) ? $tattr['category_id'] : null;
$old_deal_id = isset($this->_oldattributes['deal_id']) ? $this->_oldattributes['deal_id'] : null;
$new_deal_id = isset($tattr['deal_id']) ? $tattr['deal_id'] : null;
if ($old_cat_id != $new_cat_id || $old_deal_id != $new_deal_id) {

Not bad, but now I need more time to understand what is happening here.

- , , . , , , /, ?

- http://seanmonstar.com/post/909029460/php-error-suppression-performance

, 100%, , " 1000000 . , Zend + Doctrine + - ? DB ..?

, ( PHP).

, E_NOTICEs, . , , ?

:

class Item extends CActiveRecord {
    private $_oldattributes = array();

public function afterFind()
{
    // Save old values
    $this->_oldattributes = $this->getAttributes();
    $this->_oldcategory = $this->category;
    $this->_olddeal = $this->deal;
}

null, :

$tattr = $this->getAttributes();
$this->_oldattributes['category_id'] != $tattr['category_id']

, , , ?

, Yii, , , - , :

$this->deal->item->id != $this->_olddeal->item->id

, , , :

if ($_GET['foo']) ...

, , , , :

if (isset($_GET['foo']) && $_GET['foo']) ...

if (@$_GET['foo']) ...
+2
2

,

$this->_oldattributes['category_id']

, , , .

class Attributes {
  public $categoryId;
  // and so on
}

, isset(), (, null), ( "Undefined property" ) , , , "" isset(), .

+3

undefined, , , . , , , , PHP.

+1

All Articles