Jump to content

Fix warnings


jaymc

Recommended Posts

General question..

 

Im making a new website and at the moment I have error reporting set to display warnings for debugging.

 

However, when for instance I do a foreach() :  if the array is empty a warning error is displaed "invalid argument supplied for foreach()"

 

Should I be checking if the array is empty before doing a foreach even if no harm can be done either way code side

 

I turn warning errors off once I release live so even though they are there they will never cause any issues.

 

It just seems very tedious to me to have if (!empty($array)) {foreach().......} any time I want to do a foreach on an array that may not contain any elements

 

Your thoughts please?

 

p.s - I know its good practice.. but seriously.. do you bother with the example given above?

Link to comment
https://forums.phpfreaks.com/topic/169168-fix-warnings/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.