Hello
this is what I normally use:
if (defined $var(x)) {...}
Regards
Javi
Message: 4 Date: Tue, 6 Mar 2012 20:05:32 -0600 From: Krishna Kurapati kkurapat@gmail.com Subject: [SR-Users] Improving Kamailo configuration parser ... To: kamailio users sr-users@lists.sip-router.org Message-ID: <CAOzCjAfcaRQ+HT3r+mwckPyaVJH+EVFWNa_Hj6tAhGyD2DaMJA@mail.gmail.com
Content-Type: text/plain; charset="iso-8859-1"
I used
if ($var(x) != null) { ... }
in one of the routes, and tried to run Kamailio server. The server exited with an error. I did not know why.
Once I changed it to if ($var(x) != $null) {} the error went away. I missed $ infront null. I think it is hard to trace such problems once a large chunk of logic is written since many of us come from C++ and scripting background where $null is not a common practice.
Also if I tried to use if (!$var(x)) { ... } Kamailio tries to convert the value of $var(x) to integer. prints WARNINGS in the log when the $var(x) consists of a string.
Krish Kura