Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notice: Undefined index: XXX - Does it really matter?

Since i changed my error reporting level to error_reporting(E_ALL | E_STRICT); I am facing this error. I can obviate from this error using isset() but the code looks so ugly!


So my question is: What if I go back to my normal settings of error reporting? does it really matter to know that something is not already defined? because it woks properly without the Notice error.

Because i have +10 inputs and i get them like that:

$username = $_POST['username'];

I also tried to pre-define the variables using this in the top on the file.

$username = null; and $username = 0; but they don't work.

Thanks.

like image 886
MoeAmine Avatar asked Nov 29 '22 20:11

MoeAmine


1 Answers

It does matter. Errors slow down PHP and you really should design you application not to throw errors. Many other languages will completely die in situations where PHP happily continues script execution.

When developing, your script should not throw any errors (even an E_NOTICE).

like image 114
Inspire Avatar answered Dec 06 '22 18:12

Inspire