Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 91771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:04:56+00:00 2026-05-10T23:04:56+00:00

Is it worth changing my code to be more portable and able to deal

  • 0

Is it worth changing my code to be ‘more portable’ and able to deal with the horror of magic quotes, or should I just make sure that it’s always off via a .htaccess file?

if (get_magic_quotes_gpc()) {     $var = stripslashes($_POST['var']); } else {     $var = $_POST['var']; } 

Versus

php_flag magic_quotes_gpc off 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T23:04:56+00:00Added an answer on May 10, 2026 at 11:04 pm

    Don’t accommodate both situations. Two code paths = twice the headaches, plus there’s a good chance you’ll slip up and forget to handle both situations somewhere.

    I used to check if magic quotes were on or off, and if they were on, undo their magic (as others in the thread have suggested). The problem with this is, you’re changing the configured environment (no matter how stupid) that another programmer may expect.

    These days I write code as though magic quotes are off, and in my main include/bootstrap/always-runs file I check if magic quotes are on or off. If they’re on I throw an Exception that explains why this is a bad thing, and provide instructions on how they can be turned off.

    This approach allows you to code to a single behavior, encourages other folks using your code to configure their servers correctly (magic quotes is going away in PHP 6), and if someone really needs magic quotes on they can handle your exception and take their lives into their own hands.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hopefully a picture is worth a thousand lines of code because I don't want
Are primitives worth keeping? Should all the deprecated stuff be deleted? Do we need
Is it worth using Comet for events that are not needed in realtime, but
Is it worth learning the convention or is it a bane to readability and
Is it worth designing a system to expect test accounts and products to be
Is it worth it to develop WAP webpage for cellular since now cellular have
Which C#/.NET Dependency Injection frameworks are worth looking into? And what can you say
Ruby is truly memory-hungry - but also worth every single bit. What do you
Are there any other IDEs worth my time for Lotus Notes development? We're doing
I'm wondering if it's worth the server time when updating a record to retrieve

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.