$ _ GET ['goods _ id'] + 0 usage details

Source: Internet
Author: User
This article is about $ _ GET [ Purpose:To prevent SQL injection, tid and goods_id are all positive integers? Tid = 1 or 1.
Principle:No matter how sinister your parameter is, after + 0, it turns into a numeric type.

For example '? Tid = 1 or 1', $ _ GET ['tid'] + 0, and the value is 1;

Some students asked why you don't need to convert (int) strongly or intval.
1: Which method is used for the same purpose?
2: + 0. it only needs to be 2 characters, 5 for (int), and 8 for intval.
3: For + 0, I don't need to worry about whether $ tid is an integer, float type, or a long integer larger than 2 ^ 32 (such as getting bigint in mysql). + 0 can be used.
However, a strong conversion will cause overflow. of course, you can say that I use float for conversion. isn't it a different score.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.