Reputation: 81
I have been using php for webapp development and constantly i come across variable not defined or index not defined error/warning.
Usally we do check it by isset(variable) or empty() . But the problem I is that I have to write code for checking my entire variables(which can be empty) null or not by functions isset(variable) or empty() ,this makes code ugly.
Can anyone suggest any aother method rather than checking variables before using it??
Upvotes: 0
Views: 122
Reputation: 5221
It's best to always define your variables before use.
I normally declare my variables with a default value. So you always know its going to be defined.
Upvotes: 1
Reputation: 661
You should always define variables in php. But if you really want to do things wrong, you can always disable E_NOTICE in PHP:
error_reporting(E_ALL & ~E_NOTICE);
Upvotes: 0