I just turned on notices because it has some important information I need with debugging… with that being said, I find the undefined variables to be a real pain in the butt.
For example, to remove an undefined variable notice I have to turn the following code:
if($the_month != $row['the_month'])
into
if(isset($the_month) && $the_month != $row['the_month'])
Is there another way around this? This solution seems like a time waster to me.
Define the variable before using it. It’s the only way to be sure.
A lot of web hosts still have
register_globalsenabled. This allows any visitor to inject variables into your script by adding stuff to the query string.For example, if your script is called as
example.php?the_month=5, the variable$the_monthis automatically filled with 5. This can be very dangerous, because someone might be able to mess with important variables related to security! For this reason,register_globalsis now deprecated.But that doesn’t change the fact that a lot of web hosts still have it enabled, so every PHP developer must define every variable to something safe before using it. Otherwise you have no guarantee that the variable will contain what you think it does.