Jump to content

Why get works before being declared in variable?


Bentley4

Recommended Posts

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;
}

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.

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.