> -----Original Message----- > From: Miguel Cruz [mailto:[EMAIL PROTECTED]] > Sent: 29 April 2002 05:34 > > On Sun, 28 Apr 2002, Richard Emery wrote: > > The answer is: > > $file_pointer = fopen('/public_html/emails.txt', "a") or exit; > > > > The " || " is a binary operation. You want "or", the > logical operation. > > Yeah, Perl habit. > > But || is logical too (it's | that's binary), it just seems > to result in > $file_pointer being recast from 'resource' to 'boolean' for > some reason. > > This side effect is not mentioned at > http://www.php.net/manual/en/language.operators.logical.php where it > imples that the only difference is precedence. I'd say this is a bug > either in the manual or in PHP itself.
Surely this is *precisely* due to the difference in precedence. The or operator has lower precedence than =, whereas || has higher precedence, so: $file_pointer = fopen(...) or exit; would be ($file_pointer = fopen(...)) or exit; (i.e. evaluate the assignment expression first, and if it returns a false value then exit) whereas $file_pointer = fopen(...) || exit; would be $file_pointer = (fopen(...) || exit); (i.e. evaluate the Boolean or first, casting the fopen() result in the process, then assign the result to $file_pointer (assuming exit hasn't already terminated execution by then!)). So, no bug, no unexpected side-effects, just a logical result of applying the precedence rules strictly as advertised! 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: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php