Simple Machines Community Forum

General Community => Scripting Help => Aiheen aloitti: eriktm - huhtikuu 23, 2007, 02:30:20 IP

Otsikko: PHP $_GET
Kirjoitti: eriktm - huhtikuu 23, 2007, 02:30:20 IP
I know this been posted before, but I can't find it.

How does the PHP $_GET -function works?
On my site I want a parameter like ?p=home, ?p=about and so.

Can anyone post a "tutorial" or give me a link to another post where this is described?

-- Erik™
Otsikko: Re: PHP $_GET
Kirjoitti: Thantos - huhtikuu 23, 2007, 03:02:27 IP
$_GET gets populated with variables and values passed by GET instead of by POST, which in your browser is often show as URL variables.

So if you want ?p=home, ?p=about, etc you can simply do:


if ($_GET['p'] == 'home')
   // do something
else if ($_GET['p'] == 'about')
  // Do something else
else
  // Do something when nothing is specified.
Otsikko: Re: PHP $_GET
Kirjoitti: eriktm - huhtikuu 23, 2007, 03:06:52 IP
Okay, thanks.
I thought it was like that, but wasn't sure

-- Erik™
Otsikko: Re: PHP $_GET
Kirjoitti: snakeplissken - huhtikuu 23, 2007, 05:55:53 IP
While we are on the subject. Is there a difference between $_GET and $_REQUEST?
Otsikko: Re: PHP $_GET
Kirjoitti: Thantos - huhtikuu 23, 2007, 06:33:45 IP
Lainaus käyttäjältä: http://www.php.net/manual/en/reserved.variables.phpAn associative array consisting of the contents of $_GET, $_POST, and $_COOKIE.