Jump to content

This a necessary fix?


SirChick

Recommended Posts

<b>Notice</b>:  Undefined index:  HouseType in <b>C:\xampp\htdocs\homeloginvariables.php</b> on line <b>37</b><br />

 

Was wondering if this "needs" to be corrected? Its worked fine without me actually doing anything about it... is a problem going to arise  in future if i dont do anything about it ?

Link to comment
Share on other sites

NOTICE messages will warn you about possible bugs in your code. For example, use of unassigned values is warned. It is extremely useful to find typos and to save time for debugging. NOTICE messages will warn you about bad style. For example, $arr[item] is better to be written as $arr['item'] since PHP tries to treat "item" as constant. If it is not a constant, PHP assumes it is a string index for the array.
Link to comment
Share on other sites

Well, there are different schools of thought about this. Some believe, if it works, no need to fix it. After all, Notice errors are Notices, they aren't fatal or serious. By just turning off error reporting, problem solved.

 

However, another school of thought may suggest that this is bad practice, and a foundation for unpredictable problems later down the road (this is my belief as well)--ideally, you should prepare for errors at every possible turn and have a fallback in case it occurs, even for notice level errors.

 

While it is solely up to you which school you prefer, I'd recommend the stricter route.

Link to comment
Share on other sites

It would have different "schools" of thought if we were talking about different approaches to a problem. Actually we are talking about script errors, bugs which shouldnt be ignored, even if they dont affect the general script. As u recommended about the stricter rule, it should be a practice for all programers.

 

Actually, those who think "if it works, no need to fix it" are lazy, not very pationate about scripting or just newbies who just want to get the script done.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.