Thinkphp Write first module application _php tips

Source: Internet
Author: User
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

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.