Jeff 'Japhy' Pinyan wrote:

> 
> Strictly speaking, there is another major difference no one has mentioned
> yet (and that many people might have trouble understanding).  Using
> $count++ returns a NUMBER OR STRING, and then increments $count's value.
> ++$count increments $count's value, and returns THE SCALAR ITSELF.
> 
> How does this matter?  Well, watch:
> 
>   $i = 2;
>   $j = ++$i / ++$i;
> 
> What do you think $j will be?  3/4?  Nope.  4/4, or 1.  The reason is
> because the ++$i form is a "footnote" type of thing.  Basically it means
> "increment $i, but leave $i here" whereas $i++ means "return $i's value,
> and then increment it".
> 

I don't know what you mean by "returns THE SCALAR ITSELF"? You mean the 
actual scalar, it's lvalue? Not the case.

$i = 1;
++$i = 2;
$i++ = 2;

are both invalid for the same reason as they only return the value of $i, 
not the scalar itself. The same reason why the following statment can 
almost never be valid in most programming languages:

++$i++;

why? because both the pre and the post increment only returns the value 
(which is a constant) of $i and thus can never be assigned to anything. No 
matter which one executes first, the next increment will always fail. 

david

btw, the ++$i / ++$i gives you a 1 thing behaves differently in other 
programming languages. For example, try the following in C++:

#include<iostream.h>
void main{
        int i=2;
        int j=++i/++i;
        cout<<j<<endl;
}

won't give you a 1.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to