Skip to main content
July 23, 2012
Answered

Error notices question

  • July 23, 2012
  • 1 reply
  • 675 views

Hi,

My php (development) website code now all works as it should, and tests on the database are all producing the correct results, however after setting error_reporting to show all errors I have several instances of :

Notice: undefined constant...

Notice: undefined variable...

Notice: undefined index...

I am aware that I can set error_reporting to not display any notices however my concern is that my code is secure.

How important are these notices with regards to a secure php website? any information would be greatly appreciated, I don't want to ignore any important security issues before going live.

Thank you in advance for your time.

This topic has been closed for replies.
Correct answer Ben M

Those are good to get rid of.  Show All isn't normally what's shown, but those errors mean that you have not tested whether or not the variables are set ( php isset - http://php.net/manual/en/function.isset.php ).  It's always good when writing scripts to make sure the variables are set before trying to use them in code.  Just a simple:

if ( isset( $var ) )

will do the trick.

1 reply

Ben MCommunity ExpertCorrect answer
Community Expert
July 23, 2012

Those are good to get rid of.  Show All isn't normally what's shown, but those errors mean that you have not tested whether or not the variables are set ( php isset - http://php.net/manual/en/function.isset.php ).  It's always good when writing scripts to make sure the variables are set before trying to use them in code.  Just a simple:

if ( isset( $var ) )

will do the trick.

July 24, 2012

Thank you SnakEyez02, working through my code now correcting.