search
Homephp教程php手册php $_POST $_GET 与$_REQUEST 获取提交表单详解与区别

在php中获取表单与url传过来参数有很多方法,下面我们来介绍来下关于$_post 与$_request 获取提交表单代码原理与方法.

$_post它在php只能获取由表单的 method="post" 时它才能接受到数据,如下代码:


     
 

a.php页面

<? 
	if( $_post ) 
	{ 
	 echo $_post[&#39;cn&#39;]; 
	} 
	else 
	{ 
	    echo &#39;没有获取到值&#39;; 
	} 
	 

得到的值是 获取到我了,如果我们把表单的method="get"那么就要用$_get来获取了,如下:

echo $_get['cn'] ;//这样也有值,那么我们的$_request怎么用呢,下面看 
	echo $_request['cn']; //不管你表单的method是get或post或来自url参数传的值他都可以获取到. 

那么他们有什么区别呢,根据我的总结$_post,$_get他们在效率要高到$_request,这个仔细想一下就明白了,因为前二个是有针对性的,自然不要判断是post,get的数据,页$_request他要判断提交过来的是以那种形式过来,这样就花费的一些时间.

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.