quick php question

Discussion in 'PHP' started by adamjthompson, Dec 1, 2005.

  1. #1
    Hey,

    I'm teaching myself PHP, & I have a simple question. ;)

    When PHP coders code a page like index.php?var=1234, what is the name of the function to do that?

    I don't know what the funtion name is, so I can't look it up in the manual. :-P

    Thanks.

    Adam
     
    adamjthompson, Dec 1, 2005 IP
  2. kapri65

    kapri65 Peon

    Messages:
    59
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    index.php is the filename
    var is a variable you pass to the script and
    1234 is the value of that variable.

    in the php code you can do anything with this variable

    <?php
    if ($var){
    echo $var;
    }
    ?>

    will show
    1234.
     
    kapri65, Dec 1, 2005 IP
    adamjthompson likes this.
  3. adamjthompson

    adamjthompson Well-Known Member

    Messages:
    1,242
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    125
    #3
    Thank you!!! :)
     
    adamjthompson, Dec 1, 2005 IP
  4. jbw

    jbw Peon

    Messages:
    343
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #4
    That code depends on register globals being on, which the default has been off for some time...

    you should use something like

    $var = $_GET['var'];

    in new code
     
    jbw, Dec 1, 2005 IP
  5. Shoemoney

    Shoemoney $

    Messages:
    4,474
    Likes Received:
    588
    Best Answers:
    0
    Trophy Points:
    295
    #5
    yea if your starting new its best to write code for register globals being off.
     
    Shoemoney, Dec 1, 2005 IP
  6. execute

    execute Peon

    Messages:
    301
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #6
    There is also $_REQUEST[] which includes COOKIEs, POST, and GET.
    But doing ?var=1234 this is called a GET request.
     
    execute, Dec 2, 2005 IP