Hi All,
I have a simple doubt: are these snippets the same?
*One:*
secf_check_country($hdr(X-SRC-IP-CC)); $var(secf_cc_rc) = $rc; if ($var(secf_cc_rc) == -2) { ...
*Two:*
$var(secf_cc_rc) = secf_check_country($hdr(X-SRC-IP-CC)); if ($var(secf_cc_rc) == -2) { ...
They both seem to work, the docs say to use option -one-. In case they do the same, is there a reason I should pick one over the other? Or is this purely cosmetic?
Thanks, Joel.
Hi All,
Just to add some context to my previous question: I'm trying to understand the difference between assigning the return value of a function to a variable directly vs assigning the “$rc” value to a variable after the function has run.
Rereading my initial email, I hope this makes my question clearer 🤣🤣
Thanks again, Joel
On Wed, Jun 11, 2025 at 16:46 Joel Serrano joel@textplus.com wrote:
Hi All,
I have a simple doubt: are these snippets the same?
*One:*
secf_check_country($hdr(X-SRC-IP-CC)); $var(secf_cc_rc) = $rc; if ($var(secf_cc_rc) == -2) { ...
*Two:*
$var(secf_cc_rc) = secf_check_country($hdr(X-SRC-IP-CC)); if ($var(secf_cc_rc) == -2) { ...
They both seem to work, the docs say to use option -one-. In case they do the same, is there a reason I should pick one over the other? Or is this purely cosmetic?
Thanks, Joel.
Hello,
I think both statements should be work similar. There used to be some special cases regarding evaluation of function return values in if-statements, but this is not the case you are referring to below. I have not tested it if this is still the case. It was discussed e.g. here https://kamailio.org/mailman3/hyperkitty/list/sr-users@lists.kamailio.org/th...
Cheers,
Henning
From: Joel Serrano via sr-users sr-users@lists.kamailio.org Sent: Donnerstag, 12. Juni 2025 21:26 To: Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org Cc: Joel Serrano joel@textplus.com Subject: [SR-Users] Re: Question about how $rc works
Hi All,
Just to add some context to my previous question: I'm trying to understand the difference between assigning the return value of a function to a variable directly vs assigning the “$rc” value to a variable after the function has run.
Rereading my initial email, I hope this makes my question clearer 🤣🤣
Thanks again, Joel
On Wed, Jun 11, 2025 at 16:46 Joel Serrano <joel@textplus.commailto:joel@textplus.com> wrote: Hi All,
I have a simple doubt: are these snippets the same?
One:
secf_check_country($hdr(X-SRC-IP-CC)); $var(secf_cc_rc) = $rc; if ($var(secf_cc_rc) == -2) { ...
Two:
$var(secf_cc_rc) = secf_check_country($hdr(X-SRC-IP-CC)); if ($var(secf_cc_rc) == -2) { ...
They both seem to work, the docs say to use option -one-. In case they do the same, is there a reason I should pick one over the other? Or is this purely cosmetic?
Thanks, Joel.