Uutiset:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu
Advertisement:

PHP $_GET

Aloittaja eriktm, huhtikuu 23, 2007, 02:30:20 IP

« edellinen - seuraava »

eriktm

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™

Thantos

$_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.

eriktm

Okay, thanks.
I thought it was like that, but wasn't sure

-- Erik™

snakeplissken

While we are on the subject. Is there a difference between $_GET and $_REQUEST?

Thantos

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.

Advertisement: