• 2020-06-07 04:05:38
  • OfStack

Purpose: In order to prevent sql injection,tid,goods_id are all positive integers. tid=1 or 1.
Principle: No matter how sinister your parameter is,+0 will always be numeric

Such as'? tid=1 or 1', $_GET['tid']+0 becomes 1;

A student asked why you didn't use (int) strong conversion or intval conversion.
1: Either way, the purpose is the same
2: Use +0, only 2 characters, use (int) 5,intval() 8.
3: For +0, I don't care if $tid is integer or floating point, or if it is larger than 2^32 (mysql for bigint), +0 will work.
And with strong turn, there will be overflow, of course you can say, I use float to turn, that is not the difference in scores.

Related articles: