Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7756843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:55:36+00:00 2026-06-01T12:55:36+00:00

Should I use E_NOTICE enabled on live server? As I can see in Why

  • 0

Should I use E_NOTICE enabled on live server?

As I can see in Why should I fix E_NOTICE errors?
everybody is again with using isset() to omit notices. I have read pros, but how about code readability?

Let’s examine 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?

Lets add isset() to omit notices:

$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.

A few bits about debugging – I never wasted a day to debug errors caused by not initialized variable. Yes, maybe half of a hour was wasted to slide down into the classes/functions but this not a big waste when comparing to losing code readability IMHO?

A few bits about performance – http://seanmonstar.com/post/909029460/php-error-suppression-performance

The difference was that suppressing the notice took 100% as long as just checking if it existed first”
Test was performed on 1000000 supressions. How many of them appears in your code, even if you use Zend+Doctrine+something else? And how many time does it takes in comparison to DB connections, etc.?

Maybe I just not used to write correct code(used only PHP for long time now).

For context we have moved our project to server which displaying E_NOTICEs, that’s why I’m asking this. I don’t know why this is a big problem to switch them off?

Another example:

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;
}

so I will have null if old attributes not exists
and:

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

which will give me what I need, and there are no errors, right?

Same with not an object error, in Yii when I have set up relations some objects may not be initialized, yes there is a kind of error, because have null value and not initialized in this case is real error sometimes:

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

This may trigger a notice but will work as intended, so you ignore the notice:

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

The problem is that I can’t ignore this, because it still throws notice
and every time when i use this I must write:

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

or:

if (@$_GET['foo']) ...
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:55:37+00:00Added an answer on June 1, 2026 at 12:55 pm

    When I look at your code, for example

    $this->_oldattributes['category_id']
    

    my first thought was, that this should probably be a class instead.

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

    The difference now is, that don’t need to use isset() anymore, because now the property exists (maybe it’s null) or it is definetely a bug (“Undefined property”) and should be fixed. I think most of your cases, that you “fixed” with isset(), are of this kind.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently, PHP would trigger (and log if logging is enabled) E_NOTICE 'errors' when accessing
I'm working on a project in C#, it's about E-learning.This project should use plug-ins
I've read I should use money , but in todays fast paced world maybe
Why sometimes I should use block and other times &block inside functions that accept
I know you should use POST whenever data will be modified on a public
I wonder how I should use the GTree (from GLib) to store data? Every
I know you should use a StringBuilder when concatenating strings but I was just
I wonder why I should use: puts In folder #{File.join ENV[HOME], projects} Instead of:
I am considering whether I should use Turbogears or Pylons for my project. I
I don't know which title I should use for this question. I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.