|
Posted by Rik G. on 05/27/06 15:20
"Jerry Stuckle" <jstucklex@attglobal.net> wrote in message
news:pbqdnZunEttRouXZRVn-gg@comcast.com...
> Rik G. wrote:
> > Coming from an Assembler/C/C++/C# background I got to say this is butt
ugly:
> >
> > <?php
> > echo "2 + 2 = " . 2+2; // This will print 4
> > echo "2 + 2 = " , 2+2; // This will print 2 + 2 = 4
> > echo "test " . 2+2; // This will print 2
> > ?>
> >
> > R.
> >
> >
>
> Not if you understand precedence. Remember, '.' has a high precedence.
The
> following all work:
>
>
> <?php
> echo "2 + 2 = " . (2+2); // This will print 2 + 2 = 4
> echo "2 + 2 = " , (2+2); // This will print 2 + 2 = 4
> echo "test " . (2+2); // This will print test 4
> ?>
OK, thanks, that looks better but still: why does it eat the strings "2 + 2
= " and "test " in case 1 and 3?
And here's for something even but uglier:
echo "2 + 2 = " . 2+3; // This will print 5
echo "2 + 2 = " , 2+3; // This will print 2 + 2 = 5
echo "test " . 2+3; // This will print 3
Navigation:
[Reply to this message]
|