Home>Article>Backend Development> what does php controller mean

what does php controller mean

藏色散人
藏色散人 Original
2021-11-26 10:44:48 3072browse

php controller refers to C in MVC, that is, Controller. The function of its controller is usually to obtain the data in the model (Model) and give it to the view (View) for display.

what does php controller mean

#The operating environment of this article: Windows7 system, PHP7.1, Dell G3.

What does php controller mean?

Implementation of the Controller layer in PHP

The role of the Controller is usually to obtain and exchange data in the Model. Let the View display it, so how should we write it during development?

1. Create the class file of Controller. My file name is MatchController.class.php

getList(); // $m_match2 = Factory::M('MatchModel'); // 载入负责显示的html文件 require './template/match_list_v.html'; } /** * 比赛删除 */ public function removeAction(){ } }

2. Instantiate the controller object (front-end controller or request dispatcher) in the entry file ), the file name is index.php

In order to allow index.php to perform the actions we want to operate, some parameters should be passed to index.php to tell the entry file how to do it.
If we want to delete a game information in the game list (Game Controller), we can pass the parameters to index.php like this:

index.php?c=match&a=remove&id=N

The corresponding HTML file should be written like this:

what does php controller mean

Pass parameters to index.php through click events

index.php:

 $action_name();//可变方法

what does php controller mean

Recommended learning: "PHP video tutorial

The above is the detailed content of what does php controller mean. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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