HI all,
I have this in a snippet:
($_FILES[$fieldname]['error'] == 0)
or error($errors[$_FILES[$fieldname]['error']], $uploadForm);
and I do NOT understand one bit what it does.
$_FILES is clear,
function error is clear,
but how does
(a==b)
or (do something);
work. Some alternative if statement syntax perhaps?
Clueless
Dennis
syntax help logic operator
Moderator: General Moderators
Re: syntax help logic operator
Code: Select all
($_FILES[$fieldname]['error'] == 0) or error($errors[$_FILES[$fieldname]['error']], $uploadForm);Code: Select all
if (!($_FILES[$fieldname]['error'] == 0)) error($errors[$_FILES[$fieldname]['error']], $uploadForm);The effect is that if there is no error, nothing happens, but if there is then error() will be called and the script will (probably) terminate.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: syntax help logic operator
Yes, it is just normal operator precedence. If the left side of an OR is false the right side is never executed. If the left side is true then the right side is executed. It is not really explained in the manual, but you can look at the for exit() and the @ operator.
(#10850)