当前位置: 首页 > 网络学院 > 服务端脚本教程 > PHP > PHP $_GET

PHP
php 无限分类的实现
常用PHP代码
windows下安装配置php视频教程
MySQL数据库结构和数据的导出和导入
PHP实现 IP Whois 查询
PHP5 this,self和parent关键字详解
PHP 安全技巧连载 #1[译]
PHP 安全技巧连载 #2[译]
PHP 安全技巧连载 #3[译]
PHP 安全技巧连载 #4[译]
PHP 安全技巧连载 #5[译]
PHP 安全技巧连载 #6[译]
PHP 安全技巧连载 #7[译]
PHP 安全技巧连载 #8[译]
PHP 安全技巧连载 #9[译]
PHP 安全技巧连载 #10[译]
PHP 安全技巧连载 #11[译]
PHP error_reporting的使用
PHP 安全技巧连载 #12
使用PHP做Linux/Unix守护进程

PHP $_GET


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-01   浏览: 1464 ::
收藏到网摘: n/a

The $_GET variable is used to collect values from a form with method="get".
PHP $_GET变量是通过get方法从表单中获取“值”的。


The $_GET Variable
$_GET变量

The $_GET variable is an array of variable names and values sent by the HTTP GET method.
$_GET变量是一个包含名称[name]和值[value]的数组(这些名称和值是通过HTTP GET方法发送的,且都可以利用)。

The $_GET variable is used to collect values from a form with method="get". Information sent from a form with the GET method is visible to everyone (it will be displayed in the browser's address bar) and it has limits on the amount of information to send (max. 100 characters).
$_GET变量使用“method=get”来获取表单信息。通过GET方法发送的信息是可见的(它将显示在浏览器的地址栏里),并且它有长度限制(信息的总长度不能超过100个字符[character])。

Example
案例

<form action="welcome.php" method="get">
Name: <input type="text" name="name" />

Age: <input type="text" name="age" />
<input type="submit" />
</form>

When the user clicks the "Submit" button, the URL sent could look something like this:
当用户点击“提交Submit”按钮后,URL将会以下面的方式显示:

http://www.w3schools.com/welcome.php?name=Peter&age=37

The "welcome.php" file can now use the $_GET variable to catch the form data (notice that the names of the form fields will automatically be the ID keys in the $_GET array):
“welcome.php”文件可以使用“$_GET”变量来获取表单数据(注意:表单栏[form field]内的名称将会自动作为“$_GET”数组中的ID关键词):

Welcome <?php echo $_GET["name"]; ?>.<br />

You are <?php echo $_GET["age"]; ?> years old!

 


Why use $_GET?
为什么要使用“$_GET”?

Note: When using the $_GET variable all variable names and values are displayed in the URL. So this method should not be used when sending passwords or other sensitive information! However, because the variables are displayed in the URL, it is possible to bookmark the page. This can be useful in some cases.
要点:当使用“$_GET”变量时,所有的变量名和变量值都会显示在URL地址栏内;所以,当你发送的信息包含密码或是其他一些敏感信息时,就不可以再使用这种方法。由于所有的信息都会在URL地址栏内显示,因此,我们可以把它作为标签放入收藏夹内。这在某些特定的情况下会显得非常有用。

Note: The HTTP GET method is not suitable on large variable values; the value cannot exceed 100 characters.
注意:如果需要发送的变量值过大,HTTP GET方法便不适用。发送的信息量不能超过100个字符。


The $_REQUEST Variable
$_REQUEST变量

The PHP $_REQUEST variable contains the contents of both $_GET, $_POST, and $_COOKIE.
PHP $_REQUEST变量包含$_GET, $_POST, and $_COOKIE的内容。

The PHP $_REQUEST variable can be used to get the result from form data sent with both the GET and POST methods.
PHP $_REQUEST变量可以用来获取通过“GET”和“POST”这两种方法发送的表单数据。

Example
案例

Welcome <?php echo $_REQUEST["name"]; ?>.<br />
You are <?php echo $_REQUEST["age"]; ?> years old!

评论 (0) All

登陆 | 还没注册?