Welcome Guest, Not a member yet? Register   Sign In
php function will echo but returned value is empty
#4

[eluser]mddd[/eluser]
Allright, I'm sorry, I read your post and thought you meant 'i see it in the echo statement but it doesn't return anything'. Which would be true if you don't return anything Smile

I looked again at your code. I think the problem is this: if you exchange the 'echo' for 'return' that will return the value. But only to the function that called it. You are dealing with a recursive function so the previous iteration must also return a value to ITS caller, and so on until you get to the first call, which is in your "main code". See what I mean? Right now, the end value is known only in the last call to the function, which is the one where you find 'parent==0'. But then the value has to go back all the way to the first call. So you need to return a value on every place where the function could end. Not only when parent==0 but also when it is not: that is where you are now writing exit();


Messages In This Thread
php function will echo but returned value is empty - by El Forum - 06-07-2010, 02:22 AM
php function will echo but returned value is empty - by El Forum - 06-07-2010, 02:35 AM
php function will echo but returned value is empty - by El Forum - 06-07-2010, 02:43 AM
php function will echo but returned value is empty - by El Forum - 06-07-2010, 02:52 AM
php function will echo but returned value is empty - by El Forum - 06-07-2010, 03:03 AM
php function will echo but returned value is empty - by El Forum - 06-07-2010, 03:08 AM



Theme © iAndrew 2016 - Forum software by © MyBB