tags:

views:

1702

answers:

2

Hi

I'm just looking through a php file and have come across the following code:

switch (nvl($mode))
{
  case "add" :
     print_add_category_form(nvl($id, 0));
     break;

  case "edit" :
     print_edit_category_form($id);
     break;
}

What does the nvl() function do??

+4  A: 

Who knows? It's not a standard PHP function. Look elsewhere in the code for where that function is defined.

ceejayoz
oh ok. I have looked through and couldn't find a nvl function, so assumed it must be a standard one. Thanks anyways!
Tray
In the future, going to http://php.net/nvl will let you know if it's a standard function or not.
ceejayoz
+1  A: 

I would guess it would be like Oracle's NVL function, although as far as I know that expects two parameters.

I searched Google Code Search with PHP as the language and there are several examples like this:

/**
* If $var is undefined, return $default, otherwise return $var.
*/
function nvl(&$var, $default = "")
{
    return isset($var) ? $var
                       : $default;
}

I think however you would be better off looking for the declaration in the code yourself as ceejayoz suggests.

Tom Haigh