PHP的post数据与request数据
PHP的post数据与request数据
PHP的post数据与request数据$_POST变量(数组)
类似$_GET变量(数组),$_POST代表页面通过post方式提交过来的数据所形成的数组。
post提交数据,通常只有一种形式:
其作用是:用户填写表单数据,并提交后,会将数据发送(提交)给页面abc.php,其实也可以理解为“打开”该网页(abc.php),还可以理解为“请求”该网页(abc.php)
$v1 = $_POST['uName']; //单引号也可以用双引号,本质是一个字符串,其实是数组的键名(下标)
$v2 = $_POST['uPswd']; //该键名必须跟提交的时候的名字完全一致(区分大小写)
//也可以显示所有post数据:
var_dum($_POST)
?>
接收post数据的形式为:(在abc.php网页中)
通常,网页中的form表单,一般都用post方式,get方式一般都体现在其它3种形式
$_REQUEST变量(数组)
$_REQUEST数组,其实并不是一个独立的数据来源,而是$POST数据和$_GET数据的“总和”
即$_REQUEST数组中包括了所有$_POST数据和$_GET数据--其实是由系统内部自动存储的。
通常,$_POST数据和$_GET数据不会“同时出现”,$_REQUEST数组就代表了其中之一。
get与post数据同时提交的情形:
此时,一般只有一种html语法形式会出现该情形,如下:
则此时,uName和uPswd两个数据以post方式提交给abc.php
并同时:a=5 和 b=10两个数据,以get方式提交给abc.php
则在页面中这样取得get数据:
$v1 = $_GET['a'];
$v2 = $_GET['b];
这样取得 post数据:
$v3 = $_POST['uName'];
$v4 = $_POST['uPswd'];
但,也可以这样取得全部数据:
$v1 = $_REQUEST['a'];
$v2 = $_REQUEST['b];
$v3 = $_REQUEST['uName'];
$v4 = $_REQUEST['uPswd']
当get数据和post数据同时提交并其中有重名时说明:
wKioL1ZB0guxMIlkAABmi-th574335.jpg
1:尽量避免重名
2:如果重名了,此时$_REQUEST只会记录(存储)其中一个数据(要么get数据,要么post数据)
3:至于记录的是哪个,是由php.ini中的一个设置来决定的
request_order = "GP"; //这是默认值,G代表GET,P代表POST
其含义是:先存储GET数据,再存储POST数据
由此可见,如果重名,此时POST数据会覆盖GET数据
改为:request_order = "PG",顺序反过来。。。。。
注:$_REQUEST、$_GET、$_POST三种数据相互独立!
$_SERVER变量(数组)
该变量存储了服务器端或客户端的一些请求信息或设置信息,比较多,而且不同的服务器和不同的请求页面,其数据项都可能不同。
常用的有:
REMOTE_ADDR 用户的IP地址
SERVER_ADDR 服务器端的IP地址
SERVER_NAME 服务器名(主机名)
DOCUMENT_ROOT 站点绝对路径(其实就是主机设置中的DocumentRoot
PHP_SELF 当前网页的文件路径
QUEER_STRING 表示一个get请求的整体字体串,类似这样:
http://www.abc.com/abc.php?a=5&b=10 链接地址中的 “a=5&b=10”
输出所有项(可能每台服务器有所差异): 9000000000000000

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7
