Get variable values directly in PHP [Post,get,cooie] without $_get character escapes _php tutorial

Source: Internet
Author: User
This article introduces a global is also commonly used by a PHP to get the variable value of the method, the need for friends can refer to.
code as follows copy code

"!--?
function my_addslashes ($s Tring, $force = 0) {
!defined (' MAGIC_QUOTES_GPC ') && define (' MAGIC_QUOTES_GPC ', GET_MAGIC_QUOTES_GPC ());
if (! MAGIC_QUOTES_GPC | | $force) {
if (Is_array ($string)) {
foreach ($string as $key = + $val) {
$string [$key] = My_addslashes ($val, $f Orce);
}
} else {
$string = addslashes ($string);
}
}
return $string;
}
foreach (Array (' _cookie ', ' _post ', ' _get ') as $_request) {
foreach ($$_request as $_key = $_value) {
$ _key{0}! = ' _ ' && $$_key = my_addslashes ($_value);
}
}
Echo $urls;
?

Here we use foreach to traverse the variable to determine if the Cookie,post,get method is used, so that whenever I use the My_addslashes program directly, it will automatically distinguish the value from Post,get,cookie.

http://www.bkjia.com/PHPjc/629120.html www.bkjia.com true http://www.bkjia.com/PHPjc/629120.html techarticle This article introduces a global is also commonly used by a PHP to get the variable value of the method, the need for friends can refer to. Code to copy code as follows? function My_addslashes ( ...)

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