Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Rick Hays
Added: Feb 6, 2018 4:55 PM
Modified: Feb 6, 2018 5:01 PM
Views: 11
Tags: php
Returns Default if Field is BLANK or NULL
  1. /**
  2.  * IfNull - Returns Default if Field is BLANK or NULL
  3.  * @param string $field_name - name of field to test.
  4.  * @param string $default [optional] - Default value to pass back if $FieldName is blank
  5. */
  6. function IfNull($field_name, $default=NULL)
  7. {
  8.         if ($field_name == "" || !isset($field_name))
  9.         {
  10.                 return $default;
  11.         }
  12.         else
  13.         {
  14.                 return $field_name;
  15.         }
  16. }
  17.