|
|
Posted by jodleren on 11/29/07 06:21
On Nov 28, 12:35 pm, Captain Paralytic <paul_laut...@yahoo.com> wrote:
> On 28 Nov, 09:24, jodleren <sonn...@hot.ee> wrote:
>
>
>
>
>
> > Hi!
>
> > In while (false !== ($file = readdir($handle)))
>
> > what happens?
> > The $file gets assigned, and the value of that is compared with false?
> > The assignment is being compared with false
>
> > Say, I want to return true or an error code. Can I do;
>
> > if($err = somefunc())
> > echo "ok"
> > else
> > echo "error: $err";
>
> > WBR
> > Sonnich
>
> if($err = somefunc())
> echo "ok"
> else
> echo "error: $err";
>
> may work.
>
> An assignment "returns" the value that was assigned. This is why you
> can do:
>
> $a = $b = $c = 5;
>
> and all 3 variables will have the value 5.
>
> In your "if" comparison, any non-empty or non-zero value in the
> brackets will be taken to be true.
>
> So, if somefunc() returns 0 or nothing for a good result, then your
> statement will do what you want.- Hide quoted text -
>
> - Show quoted text -
If found, that it does not work, so I ended up using this
$err = somefunc();
if($err===true)
echo "ok"
else
echo "error: $err";
and probably I'll change it to return 0 as no error.
WBR
Sonnich
Navigation:
[Reply to this message]
|