Thinkphp Write the first module application _php tutorial

Source: Internet
Author: User
Find the project folder below the Lib/action this directory, there is a good example to create IndexAction.class.php, join us to create the admin this project, then./admin/lib/action/ IndexAction.class.php, this module is the default loaded module. In thinkphp, the auto-loaded actions, methods, actions, and so on are all named by index.
Below, we create a module of our own, such as useraction,class.php (note naming rules), we edit this file:
Copy CodeThe code is as follows:
First inherit the action class, note: The file name 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 came to the user module ';
}
Method (action, action) naming rule is: 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.

http://www.bkjia.com/PHPjc/325155.html www.bkjia.com true http://www.bkjia.com/PHPjc/325155.html techarticle Find the project folder below the Lib/action this directory, below a good example of the creation of IndexAction.class.php, join us to create the admin this project, then./admin/lib/action/ ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.