This article mainly introduces the method of judging post, ajax, and get requests in the CI framework. It has certain reference value. Now I share it with you. Friends in need can refer to it
We have to make our own wheels. Next, we will introduce how to define these methods for judging requests. Actually, it's really simple.
First open constants.php, which is a file that defines constants. Then add these lines of code to the file.
//定义请求数据的方法 define('IS_POST',strtolower($_SERVER["REQUEST_METHOD"]) == 'post');//判断是否是post方法 define('IS_GET',strtolower($_SERVER["REQUEST_METHOD"]) == 'get');//判断是否是get方法 define('IS_AJAX',isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');//判断是否是ajax请求
Then, you can call these methods in the controller file.
The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!
Related recommendations:
How to view logs in laravel in the terminal
Introduction to nginx memcache cache
The above is the detailed content of Methods for judging post, ajax, and get requests in the CI framework. For more information, please follow other related articles on the PHP Chinese website!