Php filters out url insurance

Source: Internet
Author: User
Tags php error
Php preg_match_all ([0-9]) ([% + -. 0-9A-Z _] +) I, $ _ SERVER [QUERY_STRING], $ _ GET); $ _ GET ($ _ GET [0]? Array_combine ($ _ GET [1], $ _ GET [2]): array () + php for url security filtering
Preg_match_all ('/([0-9]) = ([\ % \ + \-\. \/0-9 \ = A-Z \ _] +)/I ', $ _ SERVER ['query _ string'], $ _ GET ); $ _ GET = ($ _ GET [0]? Array_combine ($ _ GET [1], $ _ GET [2]): array () + array_fill (0, 10 ,'');


Now your $ _ GET only accepts 0-9 settings. of course, these URLs are safe.

? 0 = 123 & 1 = 456 invalid URL & 2 = 789 "AND xxx = 1 & 3 = 0ABC & 4 = BASE64_CODE & 5 = URLENCODE

Look

Acceptable URL [\ % \ + \-\. \/0-9 \ = A-Z \ _] +

Can understand and set null for non-existent settings to prevent errors

Generally, the isset ($ _ GET [0]) can be changed to $ _ GET [0] without warning information.

The $ _ GET 0-9 does not exist.

Some people say that direct variables do not have warning information ?? Me ..

Explanation without warning does not mean no warning is generated

Set the highest error reporting level.

Error_reporting (8191 );

Are you sure you have? I have tested PHP error messages well and fast.

See why isset () is used in php ()

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.