eTianbun Posted January 8, 2012 Share Posted January 8, 2012 I have seen some URL with question mark and equal sign, but i just dont understand how it works. E.g: http://doma.in/dir/page.php?=2265 what is the main reason for the question mark and equal sign in .php files? Thanks in adv! Link to comment Share on other sites More sharing options...
birbal Posted January 8, 2012 Share Posted January 8, 2012 it pass the key value pair to page.php as GET method.itlooks like http://doma.in/dir/page.php?var=2265 so in page.php $_GET['var'] will hold 2265 Link to comment Share on other sites More sharing options...
eTianbun Posted January 8, 2012 Author Share Posted January 8, 2012 Thanks, but i will be glad if you explain more on it. Link to comment Share on other sites More sharing options...
TheGallery Posted January 8, 2012 Share Posted January 8, 2012 The question mark and the equal sign is used to pass variables from the URL. Let's say we have this url http://www.sampleurl.com/index.php?name=john name=john is a pair of variable-value. The variable $name has the value of john. In order to get the value of the variable you have to use the $_GET variable like this $_GET['name'] Link to comment Share on other sites More sharing options...
boen_robot Posted January 8, 2012 Share Posted January 8, 2012 Thanks, but i will be glad if you explain more on it.Everything after "?" is pairs of name and a value. The "=" separates the name and value, and "&" can be used to pass several pairs. It's possible to have an empty string as a name, sopage.php?=2265 means that within the page.php file, $_GET[''] will hold the value 2265.The URL could also look like (for example) page.php?=2265&lang=en in which case, page.php will be able to use $_GET['lang'] to get the value "en".The purpose of query strings is to let a single PHP file deal with multiple inputs. The same "program" that gets executed for page.php?=2265 also gets executed for page.php?=1 except that the value of $_GET[''] that page.php will work with is "1", which would supposedly end up displaying something different on screen. Link to comment Share on other sites More sharing options...
eTianbun Posted January 8, 2012 Author Share Posted January 8, 2012 Roger that!THANKS GUYZ! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.