Skip to Content
PHP编程:第4版
book

PHP编程:第4版

by Kevin Tatroe, Peter MacIntyre
January 2021
Intermediate to advanced
505 pages
9h 45m
Chinese
Publishing House of Electronics Industry
Content preview from PHP编程:第4版
处理表单
193
HTTP_REFERER
表示浏览器指出的当前页面来自哪个页面(例如,
http://www.example.com/last_
page.html
)。
处理表单
PHP
处理表单是很容易的,表单参数会被放在
$_GET
$_POST
数组中。本节会介绍
很多技巧和技术,以便更容易地处理表单。
方法
如之前所讲,客户端有两个
HTTP
方法可以将表单数据传递到服务器
GET
POST
。表
单通过
form
标签的
method
属性来指定方法。理论上,方法是大小写不敏感的,但实际
上一些老版本的浏览器要求方法名为大写。
一个
GET
请求会把表单参数编码到
URL
中,叫作“查询串”,跟在
?
后面的就是查询串:
/path/to/chunkify.php?word=despicable&length=3
一个
POST
请求在
HTTP
请求的正文中传递表单参数,而
URL
保持不变。
GET
POST
最显著的不同是在
URL
行。因为在
GET
请求中所有的表单参数都被编码到
URL
上,用户可以记录下
GET
请求。然而在使用
POST
时不能这样做。
GET
POST
请求最大的不同反而是最微妙的。
HTTP
规范中讲到,
GET
请求是
幂等
的,
也就是说,一个
URL
中包含参数的
GET
请求,每次请求该
URL
,结果都是一样的。因此,
浏览器也可以缓存这些
GET
请求的响应页面,因为不管响应页面加载了多少次都不发生
改变。由于幂等性,
GET
请求只可以用于响应页面不会改变的查询,如将单词拆分为小
块或做数字乘法等。
POST
请求不是幂等的。这意味着它不能被缓存, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

解密金融数据

解密金融数据

Justin Pauley
算法技术手册(原书第2 版)

算法技术手册(原书第2 版)

George T.Heineman, Gary Pollice, Stanley Selkow
Java持续交付

Java持续交付

Daniel Bryant, Abraham Marín-Pérez

Publisher Resources

ISBN: 9787121404634