Jump to content

Question about $_GET variable


Recommended Posts

Hi,

 

I am relatively comfortable using $_GET variable. But it comes with '&'(ampersand) I have no idea what is going on. I mean please see blow:


http://www.example.com/example.php?sid=0&tid=2

Why does it need two(or more) ids and ampersand inbetween? Please explain what is going on.

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/204847-question-about-_get-variable/
Share on other sites

My point is;  how does each paramater work?

 

Does it work separately? My guess is they work Like this:

$_GET['sid'];
$_GET['tid'];

 

So as far as I can guess they are two separate params and if sid points page1(of some website) tid indicates element1 (of page1 ) at the same time. Ahhhhhhhwwwwww I am getting confused. Could anyone please show me some kind of easy-to-understnad example?!!

 

Thanks

You are just confusing yourself.  It is very, very straight-forward in that these are simply two values being carried through the URL (in this case).  These variables are can then be used on a page like so:

 

<?php
$sid = $_GET['sid']; //$sid is now 0
$tid = $_GET['tid']; //$tid is now 2

 

Or could be this:

 

<?php
//http://www.example.com/example.php?colour=red
$colour = $_GET['colour']; //$colour = red

 

This is handy for carrying values from page to page for whatever reason your code calls for it.  As was mentioned, the & is just a delimiter and you do nothing with it, it's just a method of separating the parameters, and you can have as many parameters in the URL as you please.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.