ÍøÂçѧԺ w3popÉçÇø ÍøÂç×ÊÔ´ ITÐÂÎÅ

w3pop.com :: ÍøÂçѧԺ :: PHP :: PHP $_GET

»áÔ±µÇ½

ÕʺÅ

ÃÜÂë

»Ø´ð

¼ÇסÃÜÂë

Íü¼ÇÃÜÂë? ×¢²á

PHP
WINDOWSϰ²×°MyS..
PHP ÖÆ×÷ ÍøÕ¾/·þ..
ÓÃPHPºÍCSSÖÆ×÷»î..
PHP µ¥¼þģʽ
PHP MVCģʽ£¬Àà·..
PHP ÖÐʹÓÃÕýÔò±í..
PHP ·ÀÖ¹ SQL ×¢È..
PHP ¿çÕ¾µã½Å±¾¹¥..
PHP ·ÀÖ¹Óû§²Ù×Ý..
PHP ·ÀÖ¹Ô¶³Ì±íµ¥..

PHP $_GET


×÷Õß:w3pop.com ·­Òë/ÕûÀí:w3pop.com ·¢²¼:2007-04-28 ÐÞ¸Ä:2007-08-04 ä¯ÀÀ:7709 :: ::

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µØÖ·À¸ÄÚÏÔʾ£¬Òò´Ë£¬ÎÒÃÇ¿ÉÒÔ°ÑËü×÷Ϊ±êÇ©·ÅÈëÊղؼÐÄÚ¡£ÕâÔÚÄ³Ð©ÌØ¶¨µÄÇé¿öÏ»áÏԵ÷dz£ÓÐÓá£

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!

ÆÀÂÛ (4) 1 All