the fact that $var cannot hold value seems to be a constant cause of
confusion. opensips version 1.9.0 has this:
$var() script variables have now an explicit value of NULL, so values
can be (a) integer, (b) string or (c) NULL. The NULL value can be tested
in an "if" conditions
i don't know how it is implemented, but might be a good idea for
kamailio too.
-- juha