CakeFest 2024: The Official CakePHP Conference

$_GET

$_GETHTTP GET 变量

说明

通过 URL 参数(又叫 query string)传递给当前脚本的变量的数组。 注意:该数组不仅仅对 method 为 GET 的请求生效,而是会针对所有带 query string 的请求。

示例

示例 #1 $_GET 范例

<?php
echo 'Hello ' . htmlspecialchars($_GET["name"]) . '!';
?>

假设用户访问的是 http://example.com/?name=Hannes

以上示例的输出类似于:

Hello Hannes!

注释

注意:

“Superglobal”也称为自动化的全局变量。这就表示其在脚本的所有作用域中都是可用的。不需要在函数或方法中用 global $variable; 来访问它。

注意:

GET 是通过 urldecode() 传递的。

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top