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

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.