Tuesday, February 10, 2026

Notes about using $var(...) in Kamailio

Everyone using Kamailio knows that $var() is a tricky beast. If you are not resetting it at the beginning of a script, you might get interesting effects later, or trying to use it with async statements is also not a good idea.

One of the things that tends to be overlooked is that now $null is implemented, despite its description in the documentation.

TL;DR: there is no $null, just a "0" (zero) value.

But one more thing is that an empty string is also not an empty string, but "0". So having  a statement like

uac_replace_from("$var(name)", "...");

will give you actually "0" in a CallerID name if you made something like

$var(name) = "";

before. Tricky beast as is. 

P.S.: To add, $vn(...) will also threat empty string as $null, but in this case will do even worse making From header like

From: <null> <sip:....> 

which is just a malformed header.