Home Backend Development PHP Tutorial ThinkPHP writes the first module application_PHP tutorial

ThinkPHP writes the first module application_PHP tutorial

Jul 21, 2016 pm 03:20 PM
action lib thinkphp Down Write application turn up folder module Table of contents First this project

Find the Lib/Action directory under the project folder. There is a created example IndexAction.class.php below. The admin project we created is ./admin/Lib/Action/IndexAction.class.php. This module is the module loaded by default. In ThinkPHP, automatically loaded actions, methods, operations, etc. are named after index.
Next, we create a module of our own, such as UserAction, class.php (note the naming rules), we edit this file:

Copy code Code As follows:

<?php
//Inherit the Action class first, note: the file name must be consistent with the class name
class UserAction extends Action
{
//The default action (operation, method) loaded in each module is the index method
function index ()
{
echo 'You have come to the user module';
}
// The method (operation, action) naming rules are: the first word is lowercase followed by the first letter in capital
function listName()
{
echo 'Your name is'.$_GET['name' ];
}
}
?>

Next test in the browser:
Enter: http://thinkphp.com/admin.php?m =user, output: you have come to the user module
input: http://thinkphp.com/admin.php?m=user&a=index, output: you have come 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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/325155.htmlTechArticleFind the Lib/Action directory under the project folder. There is a created example IndexAction.class below. php, join the admin project we created, then ./admin/Lib/Action/...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

The role and practical application of arrow symbols in PHP The role and practical application of arrow symbols in PHP Mar 22, 2024 am 11:30 AM

The role and practical application of arrow symbols in PHP

Can AI conquer Fermat's last theorem? Mathematician gave up 5 years of his career to turn 100 pages of proof into code Can AI conquer Fermat's last theorem? Mathematician gave up 5 years of his career to turn 100 pages of proof into code Apr 09, 2024 pm 03:20 PM

Can AI conquer Fermat's last theorem? Mathematician gave up 5 years of his career to turn 100 pages of proof into code

How to run thinkphp project How to run thinkphp project Apr 09, 2024 pm 05:33 PM

How to run thinkphp project

How to Undo Delete from Home Screen in iPhone How to Undo Delete from Home Screen in iPhone Apr 17, 2024 pm 07:37 PM

How to Undo Delete from Home Screen in iPhone

There are several versions of thinkphp There are several versions of thinkphp Apr 09, 2024 pm 06:09 PM

There are several versions of thinkphp

How to run thinkphp How to run thinkphp Apr 09, 2024 pm 05:39 PM

How to run thinkphp

How to install thinkphp How to install thinkphp Apr 09, 2024 pm 05:42 PM

How to install thinkphp

Which one is better, laravel or thinkphp? Which one is better, laravel or thinkphp? Apr 09, 2024 pm 03:18 PM

Which one is better, laravel or thinkphp?

See all articles