title: Class and Call to a member function on a non-objec
body: <p>this time i have a hard problem. I have:</p>
  
  <p><em>[folder] (file)</em></p>
  
  <hr>
  
  <p><strong>Structure directory</strong><br /></p>
  
  <p><strong>[class]</strong><br />
   <em>- (class.page.php)</em><br />
   <em>- (class.main.php)</em><br />
  <strong>[core]</strong><br />
   - <em>(core.test.php)</em><br /></p>
  
  <p>Now <strong>class.data.php</strong></p>
  
  <pre><code>&lt;?php
    class DataTools {
  
  public function clean($string) {
  
      if (!empty($string)) {
          $string = addslashes($string);
          $string = mysql_real_escape_string($string);
          $string = (string)$string;
          $string = stripslashes($string);
          $string = str_replace(" ", "", $string);
          $string = str_replace("(", "", $string);
          $string = str_replace("=", "", $string);
          return $string;
      } else {
          echo "Error";
          die();
      }
  }  
  </code></pre>
  
  <p>Now <strong>class.page.php</strong></p>
  
  <pre><code>&lt;?php
    class Page {
    public function __construct {
    include "class.data.php";
    $data = New DataTools();
    }
  ?&gt;
  </code></pre>
  
  <p>Now <strong>core.test.php</strong></p>
  
  <pre><code>&lt;?php
    require_once "../class/class.page.php";
    $page = new Page;
    $nome = $data-&gt;clean("exemple"); // line 13
  ?&gt;
  </code></pre>
  
  <p>When i open class.test.php it display this:
  Fatal error: Call to a member function clean() on a non-object in /membri/khchapterzero/core/core.test.php on <strong>line 13</strong>( this is not important becouse i reduced the page for the topic, but the line in the original page was that i posted, the other line was comments)</p>