Hi,

Dan wrote:

> >  > if($shiny = 0){
> > This does not compare anyting, it assigns 0 to $shiny
>
> yes i know, but shouldnt this operation return true?

No, it doesn't return true.

The "=" operator returns the value of the expression on its right hand side.
Therefore, the statement given above is equivalent to (as far as the if is
concerned):

     if (0) {

because the "=" operator returns 0, the value on its right hand side.

That is why a statement like:

     a = b = c = 2

sets all the above variables to 2. Otherwise, if it were to operate the way you
think it should, it would set "c" to 2 and "a" and "b" to "true" ;-).

Hope that clears up things for you.

--
Regards,
Harshdeep Singh Jawanda.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to