title: Creating a real_escape_string() method for systems with magic quotes enabled
body: <p>The book I'm learning PHP from says that in order to prevent people using things like quotes to alter the query, you should use the real_escape_string function. The author then goes on to say that on some older systems, where magic quotes is enabled, using real_escape_string could end up double escaping some characters, so he creates this function:</p>
  
  <pre><code>&lt;?php
      function mysql_fix_string($conn, $string) {
          if (get_magic_quotes_gpc()) $string = stripslashes($string);
          return $conn-&gt;real_escape_string($string);
      }
  ?&gt;
  </code></pre>
  
  <p>Would it be okay to turn this into a method in an extended class of the mysqli class? (There isn't any real reason why I wanted to, other than that I wanted to pass in as few arguments as possible.)</p>
  
  <p>If so, is this the right way to do it?</p>
  
  <pre><code>class mysqli_extended extends mysqli {
      public function fix_string($string) {
          if(get_magic_quotes_gpc()) {
              $string = stripslashes($string);
          }
          return $this-&gt;real_escape_string($string);
      }
  } 
  </code></pre>
  
  <p>And is this a situation where a static method makes more sense? If so, how could it be rewritten as a static method, and if not, then why?</p>
  
  <p><hr/>
  Since I just asked like a million questions, I'll put a summary of them here:</p>
  
  <ol>
  <li>Is it okay to create a method for this purpose. (Are there any drawbacks to this?)</li>
  <li>Is the above code the correct way to do so?</li>
  <li>Should it be a static method?</li>
  <li>How would you make it a static method?</li>
  </ol>