The third PHP code of the week is isset and empty which allow you to determine if a variable has a value or not.
isset checks to see if the variable has a value. This function is mostly used for POST and GET variables. If used with POST or GET, it allows you to not have to do the processing for the variables unless they have a value present.
empty is basically the opposite of isset, it checks to see that the variable is empty.
Below are some examples:
[php]if ( isset ($HTTP_POST_VARS[‘username’]) ) {
// execute code if POST var is set
}
if ( empty ($HTTP_POST_VARS[‘username’]) ) {
// execute code if POST var is not set
}[/php]
The next PHP code of the week we’ll cover mysql_connect, mysql_select_db, mysql_query and mysql_close.