Home > Backend Development > PHP Problem > PHP determines whether the current request is a get or a post

PHP determines whether the current request is a get or a post

(*-*)浩
Release: 2023-02-24 15:24:01
Original
7634 people have browsed it

php get和post的区分

PHP determines whether the current request is a get or a post

1.get在浏览器回退是无害,而post会再次要求;

2.get发生的url地点能够被珍藏,而post不会;(推荐学习:PHP编程从入门到精通

3.get要求参数会被完全保存在浏览器历史记录立,而post参数不会保存;

4.get参数经由过程url通报,post放在request boby中;

5.get要求在url中通报的参数有长度限定,而post没有;

6.地址栏里GET有参数,post无参数。

是否是GET提交

function isGet(){
return $_SERVER['REQUEST_METHOD'] == 'GET' ? true : false;
}
Copy after login

是否是POST提交

function isPost(){
return ($_SERVER['REQUEST_METHOD'] == 'POST' && checkurlHash($GLOBALS['verify'])
&&(empty($_SERVER['HTTP_REFERER']) || 
preg_replace("~https?:\/\/([^\:\/]+).*~i", "\\1", 
$_SERVER['HTTP_REFERER']) == preg_replace("~([^\:]+).*~", "\\1", $_SERVER['HTTP_HOST']))) ? 1 : 0;
}
Copy after login

The above is the detailed content of PHP determines whether the current request is a get or a post. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template