For a php operator priority problem, first look at an operator priority table OperatorPrecedence (operator priority) to reference AssociativityOperatorsAdditionalInformationnon-associativeclonenewcloneandnewleft a php operator priority problem.
First look at an operator priority table
Operator Precedence (Operator priority)
Reference AssociativityOperatorsAdditional Information
Non-associativeclone newclone and new
Left [array ()
Non-associative ++ -- increment/decrement
Right ~ -(Int) (float) (string) (array) (object) (bool) @ types
Non-associativeinstanceoftypes
Right! Logical
Left */% arithmetic
Left +-. arithmetic and string
Left <> bitwise
Non-associative <<=>=<> comparison
Non-associative =! ===! = Comparison
Left & bitwise and references
Left ^ bitwise
Left | bitwise
Left & logical
Left | logical
Left? : Ternary
Right = + =-= * =/=. = % = & =|==<<=>==> assignment
Leftandlogical
Leftxorlogical
Leftorlogical
Left, sort uses
Reference & prior to = prior to and
However
Reference $ a = 100 & $ B = 200
The order according to the operator priority rules should be
Reference $ a = (100 & $ B) = 200)
But there are rules in php,
Reference Note: Although = has a lower precedence than most other operators, PHP will still allow expressions similar to the following: if (! $ A = foo (), in which case the return value of foo () is put into $.
So the actual effect is
Reference ($ a = 100) & ($ B = 200)
It is equivalent to turning & into and
In addition, an example of the reference of laruence
At the end of the reference, by the way, PHP corresponds to T_BOOLEAN_AND also defines T_LOGICAL_AND (and) and T_LOGICAL_OR (or). the priority of these two values is lower than the equal sign, so there will be, the following are typical examples of PHP tutorials:
$ Result = mysql_query (*) or die (mysql_error ());
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.