CodeIgniter $ this-> load-> model () funktioniert nicht
Ich benutze Codeigniter 2.1.2 und hier ist meine Situation gerade. Ich habe ein Modell namens math.php in C: \ wamp \ www \ cr8v \ application \ models. Ich versuche, dies von C: \ wamp \ www \ cr8v \ application \ controller \ site.php in meinen Controller zu laden, aber ich erhalte diesen Fehler:
Unable to locate the model you have specified: math_model
Hier ist der Inhalt von math.php
<?php
class Math_model extends CI_Model(){
public function add(){
return 1+1;
}
}
?>
Und hier ist der Inhalt meiner site.php
<?php
class Site extends CI_Controller{
public function index(){
$this->addstuff();
}
public function addstuff(){
$this->load->model("math_model");
echo $this->math->add();
}
}
?>
Ich habe dies in einem Tutorial auf Youtube verfolgt. Dennoch gibt es mir nicht meine gewünschte Ausgabe. Ich habe versucht, darüber zu googeln und andere verwandte Fragen damit zu lesen, aber diese Informationen sind nicht genug. Bitte helfen Sie.
BEARBEITET Ich habe das erst vor einer Weile gelesen
[http://stackoverflow.com/questions/8074368/codeigniter-php-model-access-unable-to-locate-the-model-you-specified[1]
Jetzt habe ich diesen Fehler
( ! ) Parse error: syntax error, unexpected '(', expecting '{' in C:\wamp\www\cr8v\application\models\math_model.php on line 2
Call Stack
# Time Memory Function Location
1 0.0036 148768 {main}( ) ..\index.php:0
2 0.0062 185072 require_once( 'C:\wamp\www\cr8v\system\core\CodeIgniter.php' ) ..\index.php:202
3 0.0561 784312 call_user_func_array ( ) ..\CodeIgniter.php:359
4 0.0561 784360 Site->index( ) ..\CodeIgniter.php:359
5 0.0561 784376 Site->addstuff( ) ..\site.php:4
6 0.0561 784504 CI_Loader->model( ) ..\site.php:8