Chris Boget wrote:
> Consider the following:
>
> function test() {
> static $i = 0;
>
> $i++;
> $retval = ( $i <= 10 ) ? $i : '';
>
> return $retval;
>
> }
> while( $bob = test()) {
> echo $bob . '';
>
> }
>
> You would expect the while loop to go on forever just looking
> You would expect the while loop to go on forever just looking
> at the above code. However, what's happening is that when the
> empty string is getting returned due to $i being > 10, the while
> loop is resolving FALSE when $bob is set to the value of the
> empty string.
> Is there any way that
On Saturday 18 December 2004 00:02, Chris Boget wrote:
> Is there any way that I can force this not to happen? That the
> while loop resolves as FALSE only when the function actually
> returns a (boolean) FALSE value?
Make the test more explicit:
while (TRUE === ($bob = test())) { ... }
--
J
Chris Boget wrote:
> function test() {
> static $i = 0;
>
> $i++;
> $retval = ( $i <= 10 ) ? $i : '';
>
> return $retval;
>
> }
> while( $bob = test()) {
> echo $bob . '';
>
> }
>
> You would expect the while loop to go on forever just looking
> at the above code.
4 matches
Mail list logo