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

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

(*-*)浩
(*-*)浩Original
2019-09-21 11:04:317613browse

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;
}

是否是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;
}

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!

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