An interesting topic ++ operator

$a = 3;
$b = 5;

if($a = 5 || $b = 7){

  $a++;
  $b++;

}

echo $ a. ' '$ B;

The output is "16."

Detailed:

An arithmetic priority brackets $ a = (5 || $ b = 7) 

When || operation, the foregoing is true not performed later

So in this case $ a = ture;

The braces $ a ++ after the operation, $ a is still equal ture (boolean value after the ++ operator to maintain the original type unchanged)

Therefore, when echo, $ a "." Link conversion to a string type space so the output is "16"

Reproduced in: https: //www.cnblogs.com/caly/archive/2012/12/26/2834482.html

Guess you like

Origin blog.csdn.net/weixin_33755557/article/details/93538113