Find the Lib/Action directory under the project folder, and the created example IndexAction is as follows. class. php, join the admin project we created, so. /admin/Lib/Action
Previously, we created the first ThinkPHP project. next we will create the first module application.
Find the Lib/Action directory under the project folder, and the created example IndexAction is as follows. class. php, join the admin project we created, so. /admin/Lib/Action/IndexAction. class. php. this module is loaded by default. In ThinkPHP, the automatically loaded actions, methods, and operations are all named after indexes.
Next, we will create a module of our own, such as UserAction and class. php (note the naming rules). We will edit this file:
// Inherit the Action class first. note: the file name must be consistent with the class name.
Class UserAction extends Action
{
// The default action (Operation and method) loaded in each module is the index method.
Function index ()
{
Echo 'You have come to the user module ';
}
// The naming rule for methods (operations and actions) is: the first letter followed by the first letter in lowercase
Function listName ()
{
Echo 'Your name is '. $ _ GET ['name'];
}
}
?>
Next, test in the browser:
Input: http://thinkphp.com/admin.php? M = user. output: you are in the user module.
Input: http://thinkphp.com/admin.php? M = user & a = index. output: you are in the user module.
Input: http://thinkphp.com/admin.php? M = user & a = listname. output: Your name is
Input: http://thinkphp.com/admin.php? M = user & a = listname & name = 123. output: Your name is 123.