CodeHelper CodeHelper
首页
JavaScript
PHP
Python
Git速查表 (opens new window)
博客 (opens new window)
首页
JavaScript
PHP
Python
Git速查表 (opens new window)
博客 (opens new window)
  • 开始

    • 使用
  • 函数方法

    • 请求
      • 判断请求类型
      • 获取请求参数
    • 多进程
目录

请求

# 判断请求类型

if(!function_exists('is_get')){	
    function is_get()
	{
	   return isset($_SERVER['REQUEST_METHOD']) && strtoupper($_SERVER['REQUEST_METHOD'])=='GET'; 	
	}
}

if(!function_exists('is_post'))
{	
    function is_post()
	{	   
        return isset($_SERVER['REQUEST_METHOD']) && strtoupper($_SERVER['REQUEST_METHOD'])=='POST';		
    }
}

# 获取请求参数

  • POST请求
// $_POST接收Content-Type类型为application/x-www-form-urlencoded或者multipart/form-data提交的数据
$parms = $_POST;

// php://input 读取 POST 的原始数据; 不能用于 enctype="multipart/form-data"
$parms = file_get_contents("php://input");

// HTTP_RAW_POST_DATA 在 PHP 5.6.0 中 已弃用,并在 PHP 7.0.0 中删除。
// $parms = $GLOBALS['HTTP_RAW_POST_DATA'];
  • GET请求
$parms = $_GET;
// $_GET获取参数时会自动urldecode(),无需担心url经过urlencode()编码
上次更新: 2022/11/11, 14:40:53
使用
多进程

← 使用 多进程→

Theme by Vdoing | Copyright © 2022-2023 CodeHelper
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式