日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

php 获取请求,PHP 扩展 - 获取请求信息

發布時間:2024/1/23 php 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 php 获取请求,PHP 扩展 - 获取请求信息 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

在 main/SAPI.h 下定義了會使用到的 HTTP Request 屬性,在擴展中可以引用該頭文件并使用 SG 宏來使用 SAPI 的全局變量,結構如下:

typedef struct _sapi_globals_struct {

void *server_context;

sapi_request_info request_info; // 請求信息

sapi_headers_struct sapi_headers;

int64_t read_post_bytes;

unsigned char post_read;

unsigned char headers_sent;

zend_stat_t global_stat;

char *default_mimetype;

char *default_charset;

HashTable *rfc1867_uploaded_files;

zend_long post_max_size;

int options;

zend_bool sapi_started;

double global_request_time;

HashTable known_post_content_types;

zval callback_func;

zend_fcall_info_cache fci_cache;

} sapi_globals_struct;

結構體 sapi_request_info 結構如下:

typedef struct {

const char *request_method; // 請求方法,如 GET / POST / PUT 這些

char *query_string; // Query 字符串,就是 url ? 問號后面的 GET 參數

char *cookie_data; // Cookie 串

zend_long content_length; // 請求長度

char *path_translated;

char *request_uri; // 請求 URI

struct _php_stream *request_body;

const char *content_type; // 內容類型

zend_bool headers_only;

zend_bool no_headers;

zend_bool headers_read;

sapi_post_entry *post_entry; // Post 內容

char *content_type_dup;

/* for HTTP authentication */ // 下面三個用于 HTTP 驗證

char *auth_user;

char *auth_password;

char *auth_digest;

/* this is necessary for the CGI SAPI module */

char *argv0;

char *current_user;

int current_user_length;

/* this is necessary for CLI module */

int argc;

char **argv;

int proto_num;

} sapi_request_info;

比如我現在要獲取是否為 POST 請求,那么

/* {{{ proto bool isPost(void) */

PHP_FUNCTION(isPost)

{

if (!SG(request_info).request_method) {

RETURN_FALSE;

}

RETURN_BOOL(0 == strcasecmp(SG(request_info).request_method, "POST"));

}

/* }}} */

總結

以上是生活随笔為你收集整理的php 获取请求,PHP 扩展 - 获取请求信息的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。