Re: function I created doesn't work

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jim Lucas wrote:
> afan pasalic wrote:
>> Daniel Brown wrote:
>>> On Jan 4, 2008 12:52 PM, afan pasalic <afan@xxxxxxxx> wrote:
>>>> I think you didn't understand my question: I know why the function work
>>>> in 2nd example. My question was why I'm not getting the result in 1st
>>>> example? What am I doing wrong. And, as far as I know, I think it
>>>> doesn't have anything with GLOBALS (register_globals are anyway turned off).
>>>     Also, keep in mind that, in the else{} clause of the first
>>> function, you're not using return; to send back the information.  In
>>> my opinion, you shouldn't call a function from within its own
>>> definition because it can cause a loop if the conditions are met and
>>> the else{} clause is reached over and over again.  If there is a
>>> situation where get_content(0, 0, $index1); doesn't return any rows,
>>> the function will loop eternally (that is, until PHP gets dizzy and
>>> gives up).
>>>
>> that's "recursive" function and it can call itself (though, you're
>> right, if you are not careful you can finish in loop :)).
>> and I think I don't need return in "else" statement because the result
>> to be send "back" is in "if" statement.
>>
>> -afan
>>
> 
> Trust me, you have to return in the else part, otherwise it isn't going to work!
> 

yup. you're right. didn't understand WHY I needed it there. now I got it.
:D

thanks jim.

-afan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux