Find the Lib/action directory below the project folder, and here's a good example to create IndexAction.class.php, join us to create admin this project, then./admin/lib/action/ IndexAction.class.php, this module is the default loaded module. In thinkphp, automatically loaded actions, methods, operations, and so on are named by index.
Below, we create a module of our own, such as useraction,class.php (note naming rules), we edit this file:
Copy Code code as follows:
<?php
Inherit the action class first, note: The filename should be consistent with the class name
Class Useraction extends Action
{
The actions (actions, methods) that are loaded by default in each module are the index method
Function index ()
{
Echo ' You come to the user module ';
}
Method (action, action) naming rule is: The first word lowercase followed by the first letter uppercase
function ListName ()
{
Echo ' Your name is '. $_get[' name ';
}
}
?>
Next in the browser test:
Input: Http://thinkphp.com/admin.php?m=user, Output: You came to the user module
Input: Http://thinkphp.com/admin.php?m=user&a=index, Output: You came to 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