RE: [PHP] 2 errors I can not understand
| From: | Ford, Mike | Date: | Thu, 15 Mar 2007 10:55:54 +0000 |
| Subject: | RE: [PHP] 2 errors I can not understand | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-250650@lists.php.net to get a copy of this message | ||
On 14 March 2007 22:52, Richard Lynch wrote:
> On Wed, March 14, 2007 6:52 am, Myron Turner wrote:
> > Richard Lynch wrote:
> > > On Tue, March 13, 2007 6:04 pm, Jonathan Kahan wrote:
> > > The = operator takes precedence, and $d is set to 0.
> > >
> > But why? According to the manual, the modulus operator has
> > precedence over the equals! So shouldn't this expression resolve
> > to: ($s % $d) = 0 which gives an error?
>
> Ya got me there.
>
> I hadn't even checked the precedence list before answering.
>
> Unless somebody has a rational explanation, I think this should be an
> error...
When a similar anomaly involving the ! operator was reported (http://bugs.php.net/bug.php?id=17180),
the response was that PHP is "smart" about such things and invokes the DWIM principle to
silently alter the precedence of = in certain situations. This resulted in the addition of a note
to the end of the operator precedence page at http://uk2.php.net/manual/en/language.operators.php#language.operators.precedence,
but it seems to me that this is too specific to the ! operator and should be generalized. In fact,
I'd completely forgotten that I suggested as much at the end of the bug report -- but this
hasn't been taken up, so maybe a bunch of you want to re-activate the bug report and support my
suggestion??
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@leedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm