Php-magic Quotes Simple Tutorial _php tutorial

Source: Internet
Author: User
Magic Quotes is used to filter forms submitted over illegal information processing, if (GET_MAGIC_QUOTES_GPC ()) echo "Magic quotes is enabled"; else echo "Magic quotes is D Isabled ";

PHP-magic Quotes
Before to PHP 6th there is a feature called Magic quotes created to help protect novice programmers from writing bad form processing code. Magic quotes will automatically evade dangerous form data that may be used for SQL injection with backslashes. The character escapes from PHP include: Quote ', double quote ', backslash, and null character.

However, this novice protection proves to be causing more problems than solving the problem, not in PHP 6. If any version of your PHP version is before 6th, then you should use this lesson to learn how magic quotes may affect you.

Magic quotes-they make?
First thing first, you need to check if you have magic quotes to make your server. The GET_MAGIC_QUOTES_GPC function returns 0 (close) or 1 (UP). These Boolean values are suitable for becoming a good speaker, if 1 of them are true and 0 are false.

echo "Magic quotes is enabled";
echo "Magic quotes is disabled";

Output is with you PHP is open

Magic quotes in action
It is now possible to make a simple form showing how the processor's machine with magic quotes will enable those who may escape the danger of the character. This form is presented to itself, so you just need to make a file, "Magic quotes.php" to test it.

echo "Altered Text:". $_post[' question ');

Remove backslash-s tripslashes () function
In the use of PHP backslash cleanup function stripslashes It's smart add some magic quotes like our check "they have enabled?" "The above section. In this way, you will not accidentally be removed from the slash thought to be legal, future if your PHP magic quotes settings change.

echo "removed slashes:";
Remove those slashes
echo stripslashes ($_post[' question ');
echo $_post[' question '];

?> true techarticle Magic Quotes is used to filter forms submitted over illegal information processing, if (GET_MAGIC_QUOTES_GPC ()) echo Magic quotes is enabled;else echo Magic quotes are Disabled PHP-magic q ...

  • Related Article

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