Thinkphp5.1 framework Routing:: get, post request simple usage example

Time:2019-12-13

This article describes the simple use of thinkphp5.1 framework route:: get, post request. To share with you for your reference, as follows:

1. Create a type method in the controller index under the index module

public function type(){
  var_dump(input());
  Echo 'I am the test type';
  return view();
}

2. Under the index module, create a new view, create an index folder, and create a type.html page

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form action="type" method="post">
<p>
<input type="text" name="name">
</p>
<p>
< input type = "submit" value = "submit" >
</p>
</form>
</body>
</html>

3. Set route


//Route::rule('type','Index/index/type','get');
Route::get('type','index/index/type');

//Route::rule('type','index/index/type','post');
Route::post('type','index/index/type');
// or
//Route::rule('type','index/index/type','get|post');

Design sketch:

Input 111

output

For more information about ThinkPHP, readers who are interested in it can see the following topics: introduction to ThinkPHP, summary of operation skills of ThinkPHP template, summary of common methods of ThinkPHP, introduction to CodeIgniter, advanced tutorial of CI (CodeIgniter) framework, introduction to Zend framework and technical summary of PHP template.

I hope that this article will be helpful for you to design your PHP program based on the think PHP framework.

Recommended Today

[reading notes] calculation advertising (Part 3)

By logm This article was originally published at https://segmentfault.com/u/logm/articles and is not allowed to be reproduced~ If the mathematical formula in the article cannot be displayed correctly, please refer to: Tips for displaying the mathematical formula correctly This article isComputing advertising (Second Edition)Reading notes. This part introduces the key technology of online advertising, which is […]