In the case of user, call user.php's Get_number () method
First, whether it is to call their own modules or other modules app\model\user.php the same wording
1<?PHP2 3 namespace App\index\model;4 UseThink\model;5 6 classUserextendsModel7 {8 Public functionGet_member () {9 return3;Ten } One}
Second, the user controller calls the user module (that is, the controller calls itself module)
1<?PHP2 namespace App\index\controller;3 Usethink\db;4 UseThink\controller;5 UseApp\index\model\user asUsers;6 classUserextendsController7 {8 Public functionWudi () {9 $user=NewUsers ();Ten $user=$user-Get_member (); One Echo $user; A } -}
Third, the index controller calls the user module (that is, the controller calls other modules)
<?phpnamespace App\index\controller; Usethink\db; UseThink\controller; UseApp\index\model\user;classIndexextendscontroller{ Public functionWudi () {$user=NewUser (); $user=$user-Get_member (); Echo $user; }}
Iv. Analysis
The controller calls itself module because the name is user, there will be an error.
To prevent this, rename the user to
Rename Syntax Yes (User as new name)
THINKPHP5 's controller calls its own module and calls methods of other modules