I know I'm doing something wrong here, but I've stared myself blind at the problem. I'd appreciate if anyone could help point me in the right direction.
The problem is pretty simple. The following function should be returning the value if it is greater than 5, and increment the value if it is less than 5. However, when the if criteria is met, the value returned is null. I've tried printing the result directly instead of returning it, in which case it works perfectly. What's wrong with my return command?
function go_test($num) {
if ($num > 5) return $num;
else go_test($num + 1);
}
echo go_test(1);
Note: If I feed the function with a value greater than 5 (ex. 6) the function returns the correct value (6). ??
Thanx a lot,
soulmaniac