[nycphp-talk] rtrim broken?
David Krings
ramons at gmx.net
Thu Nov 2 18:09:20 EST 2006
Hi,
I agree, that wasn't the best example to give. I probably thought
first to write $k = $k + 1, and then recalled that a + 1 is easily
expressed as ++, which also does not require to assign the result to the
same variable. It really was only meant as example and I guess I just
add two in future to make a point.
The really embarrassing thing is that if I just would have looked at
my code for some time more and did it as shown in my botched example,
the whole mess could have been prevented. I got this squared out now and
it all works and I keep on screwing my head on straight.
David K.
Warren Myers wrote:
> I don't think this does what it looks like
>
> On 11/1/06, *David Krings* <ramons at gmx.net <mailto:ramons at gmx.net>>
> wrote:
>
> Hi,
>
> yes, $text is the string passed to rtrim, which in retrun is
> supposed to overwrite what is in $text previously. Kinda like
> $k = $k++;
>
>
> $k++ will make k increase by 1. $k=$k++ still only increases $k by one
> because ++ is a postffix operator, and the assignment of $k=$k happens
> before $k is incremented with ++. $k=$k+1 is equivalent to $k++, but
> what you have is an extra assignment for no reason, or at least it
> looks like it
>
More information about the talk
mailing list