Bentley4 Posted May 12, 2011 Share Posted May 12, 2011 I don't understand why "if(isSet($_GET['sid'])) " works before it is declared in the variable name(" $name = $_GET['sid'];"). 1. How does php store the date in this get statement? 2. Is GET an array? if(isSet($_GET['sid'])) { echo "<h2>Exercise</h2>"; $name = $_GET['sid']; $timein = time(); $quest=1; $nextquest=2; } else { echo "<h2>Enter Student Number:</h2>"; $quest=0; $nextquest=0; } Link to comment https://forums.phpfreaks.com/topic/236203-why-get-works-before-being-declared-in-variable/ Share on other sites More sharing options...
MasterACE14 Posted May 12, 2011 Share Posted May 12, 2011 $_GET['sid']; comes from the URL. page.php?sid=something Link to comment https://forums.phpfreaks.com/topic/236203-why-get-works-before-being-declared-in-variable/#findComment-1214424 Share on other sites More sharing options...
jonsjava Posted May 12, 2011 Share Posted May 12, 2011 _GET is a Superglobal, which means it is always available in all scopes. Link to comment https://forums.phpfreaks.com/topic/236203-why-get-works-before-being-declared-in-variable/#findComment-1214425 Share on other sites More sharing options...
trq Posted May 12, 2011 Share Posted May 12, 2011 I don't understand why "if(isSet($_GET['sid'])) " works before it is declared in the variable name(" $name = $_GET['sid'];"). You seem to misunderstand how variable assignment works. Data is assigned to the item on the left of the = assignment operator, not the right. That means, in your example above the variable $name is being assigned the value from $_GET['sid'] not the other way around. Link to comment https://forums.phpfreaks.com/topic/236203-why-get-works-before-being-declared-in-variable/#findComment-1214436 Share on other sites More sharing options...
Bentley4 Posted May 12, 2011 Author Share Posted May 12, 2011 Thnx, I think I understand now! Link to comment https://forums.phpfreaks.com/topic/236203-why-get-works-before-being-declared-in-variable/#findComment-1214484 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.