How to return result of php methods

I have created a php method that should return a char string. I verified the value inside the method, hwever I do not get a return.

Code example
{age}=calc_age($birthDay)
I use “Definition of the parameters of the method:” to define the $birthDay parameter.

method: calc_age
{

return $age;
}

Most probably it is a simple problem, but I seem not to see the solution.
Many thanks for help

It’s as simple as you’re trying to do it.
It shoud work.

Can you add an “echo $age;” (or the sc_ajax_message($age); function, if you can’t use echo) just before the “return $age;” line?
That way you can check that $age is populated correctly and that your code runs up to the “return $age” line.

If that’s ok, the calling code should receive the returned value.
Try and set it in a local var and output that. E.g.:
$v_age = calc_age($birthDay);
echo $v_age;