PHP Fatal Error Call to undefined method
<p>I've been looking for a solution to my problem but every case seems to differ from mine. I'm attempting to import a CSV file using PHP.</p>

<p>This is the Error I receive: </p>

<blockquote>
  <p>Fatal error: Call to undefined method Teacher::email_teacher() in C:\wamp\www\Projet\models\Db.class.php on line 66</p>
</blockquote>

<p>This is from <b>index.php</b>. Thanks for your help in advance.</p>

<pre><code>&lt;?php
session_start();

define('VIEW_PATH','views/');
define('CONT_PATH','controllers/');

$csvfileTeacher = 'models/professeurs.csv';


function uploadClass($classe) {
        require 'models/' . $classe . '.class.php';
    }
    spl_autoload_register('uploadClass');


function getTeacher($csvfileTeacher) {
    $teachers = array ();
    if (file_exists ( $csvfileTeacher )) {
        $fcontents = file ( $csvfileTeacher );
        $i = count ( $fcontents ) - 1;
        for($index = 1; $index &lt;= $i; $index ++) {
            $icontent = $fcontents [$index];
            preg_match ( '/^(.*);(.*);(.*);(.*)/', $icontent, $result );
            $teachers [$index] = new teacher ( $result [1], $result [2], $result [3], $result [4] );
        }
    }
    return $teachers;
}

if (file_exists ( $csvfileTeacher )) {

    $teachers = getTeacher ( $csvfileTeacher );

    foreach ( $teachers as $teacher ) {
        Db::getInstance ()-&gt;insert_teacher ( $teacher );  ///here is where the problem seems to be 
    }

}   
</code></pre>

<p>Here is the function insert_teacher() from <b>Db.class.php:</b></p>

<pre><code>public function insert_teacher($teacher) {
    $query = 'INSERT INTO teachers VALUES ( ' . $this-&gt;_db-&gt;quote ( $teacher-&gt;email_teacher () ) . ',' . $this-&gt;_db-&gt;quote ( $teacher-&gt;firstname_teacher () ) . ',' . $this-&gt;_db-&gt;quote ( $teacher-&gt;lastname_teacher () ) . ',' . $this-&gt;_db-&gt;quote ( $teacher-&gt;supervisor () ) .')';          
    $this-&gt;_db-&gt;prepare ( $query )-&gt;execute ();
}
</code></pre>

<p>This is the teacher class:</p>

<pre><code>&lt;?php
    class Teacher{

        private $_email_teacher;
        private $_firstname_teacher;
        private $_lastname_teacher;
        private $_supervisor;

        public function  __construct($email_teacher,$firstname_teacher,$lastname_teacher,$supervisor){

            $this-&gt;_email_teacher=$email_teacher;
            $this-&gt;_firstname_teacher=$firstname_teacher;
            $this-&gt;_lastname_teacher=$lastname_teacher;
            $this-&gt;_supervisor=$supervisor;
        }

        public function email(){
            return $this-&gt;_email_teacher;
        }

        public function firstname(){
            return $this-&gt;_firstname_teacher;
        }
        public function lastname(){
            return $this-&gt;_lastname_teacher;
        }

        public function supervisor(){
            return $this-&gt;_supervisor;
        }

    }
?&gt;
</code></pre>