In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "thinkphp5 how to judge whether it is a post request". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how thinkphp5 determines whether it is a post request".
In thinkphp5, you can use the isPost () method to determine whether it is a post request. The function of this method is to determine whether the data is currently submitted by Post. If the result is true, it is judged to be a post request, if it is false, it is not a post request, and the syntax is "$this- > isPost ()".
This article operating environment: Windows10 system, ThinkPHP5 version, Dell G3 computer.
How does thinkphp5 determine whether it is a post request?
The isPost () method is used in ThinkPHP to determine whether the data is currently submitted for Post.
If I am doing an operation to add a user, we can set up a User/useradd.html as a template. Then write a UserAction.php. Write a userAdd method in UserAction.php and use isPost () to determine whether it is status or not, and you can write pre-and post-commit in an Action.
/ / users add public function userAdd () {if ($this- > isPost ()) {/ / process} else {$this- > display ('userAdd');}}
When using version 3.2 before, it is often used to
If (IS_POST) {} else {}
In thinkphp5.1, IS_POST is abolished.
In thinkphp5.1, we can use this
Introduction into the controller
Use think\ facade\ Request Public function index () {if (Request::isPost ()) {/ / this judgment} else {} Thank you for your reading. This is the content of "how thinkphp5 determines whether it is a post request". After studying this article, I believe you have a deeper understanding of how thinkphp5 judges whether it is a post request. The specific use situation still needs to be verified by practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.