RE: question about ? :
| From: | Ford, Mike [LSS] | Date: | Wed, 19 Jun 2002 13:33:36 +0000 |
| Subject: | RE: question about ? : | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-102928@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Joel Boonstra [mailto:jboonstra@gospelcom.net]
> Sent: 19 June 2002 14:00
>
> > OK, try this: why does
> >
> > $x = 3 + 5 - 7;
> >
> > produce different results from
> >
> > $x = 3 + (5 - 7);
>
> Really? It shouldn't produce different results for you -- they should
> both evaluate to '1'.
Jeez, you're right! That was dumb!! Somehow I suffered a brain-wibble that
managed to calculate 5-7 as +2 rather than -2. As I studied maths all the
way up to 1st year at university -- and do understand the rules of
precedence and associativity, honest, boss -- I really shouldn't have made
that kind of basic error.
Still, the principle I was trying to illustrate is still good, even if my
example was complete codswallop, so let's try again.
Why does:
$x = 9 - 5 + 3; // 7
produce a different result from:
$x = 9 - (5 + 3); // 1
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211