PHP using $_request details note

Source: Internet
Author: User
PHP using $_request details note

In a report program, $_request is used to receive data to query a condition, $_request[' from ', and if not passed (the default), it gets the first from the existing data. After doing it, run the test locally, pass it to the server, and test it through.

In the acceptance of the time, out of the bug, and this bug is very strange, the same program, put on the same server, the same site, the same URL, just different computers, in My Computer open by default there is data, on some machines open by default is no data.

In order to exclude is the client browser difference, I in the program the data array Print_r prints out, the result is still the same, I can print out a bunch of data here, but there is no data before the machine, output an empty array.

Many friends should have also encountered such a demand: when passing a parameter, if the form post, use the value of $_post, if not, get the value in $_get. Many people will think of $_request, because when $_get and $_post have the same name parameter, $_request is $_post, satisfies the $_ Post-priority requirements (this one is actually configured in php.ini, and the default post is preferred than get).

However, the convenience of things always bring hidden dangers. Many people in the use of $_request, all $_cookie to forget, think $_request is the $_get and $_post combination of arrays. $_request is what, which priority, in fact, according to the php.ini Variables_order parameter is determined, by default is "Egpcs".

In my case, some of the machines under a certain sub-station have a cookie named from, and the scope is *. main domain, so his on-machine $_request will have content, is $_cookie in from, and take him this from to check the data, of course, no, Oh.

Write code, do not ask for convenience, strict demands on themselves, in order to write a more robust program.

  • 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.