Generally because of "bad programming", and a possibility for mistakes now or later.
- If it's a mistake, make a proper assignment to the variable first: $varname=0;
- If it really is only defined sometimes, test for it: if (isset($varname)) ....
if (isset($varname)), before using it - If it's because you spelled it wrong, just correct that
- Maybe even turn of the warnings in you PHP-settingsPHP-settings