PHP oddities
Posted under » PHP on 29 April 2009
There are some things which I find irksome in PHP. I will list them here as I come across it.
Notice: Undefined index:
if (isset($_GET['taxo']))
{$taxo = $_GET['taxo'];}
Applies to $_GET and $_POST stuff.
Notice: Use of undefined constant
$greg=$solatime['greg'];
Without the bracket (quotes) will give an error. Notice: Use of undefined constant greg - assumed 'greg'. Not a critical error and you if you turn off all notices, you will not see the error messages.
Date and NULL issue
Not specifically a PHP issue but a MySQL one as well. You cannot insert or update "" into date format. You should use "0000-00-00" instead. You cannot use NULL most of the time because sometimes you already put "$thedatefield" hence will be translated into "NULL".
the backslash in form issue
Be carefull when your use "" or '. Some systems add a backslash while some don't. See also magic_quotes_gpc.
register globals
The older PHP version uses register globals directive set to "on". It is better that you avoid those and use super globals which look like
- $_POST says that variables in that array come from a form.
- $_GET says that variables are passed through the URI.
- $_SESSION says (more than clear) that variables are in a session.
