SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict CeleronXL's Avatar
    Join Date
    Dec 2002
    Location
    United States of America
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What Does "&" Do?

    In a situation like this, what does the & do? (&$postid):
    PHP Code:
    function getpostinfo (&$postid) {
    global 
    $DB_site;
    global 
    $postcache;
    $postid intval($postid);
    if (!isset(
    $postcache[$postid])) {
    $postcache[$postid]=$DB_site->query_first("SELECT * FROM post WHERE postid='$postid'" );
    }
    return 
    $postcache[$postid];

    So hold me when I'm here
    Right me when I'm wrong
    Hold me when I'm scared
    Love me when I'm gone.

  2. #2
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it passes the variable as a reference instead of the value, example:

    PHP Code:
    function changeIt(&$var)
    {
        
    $var++;
    }
    $something 5;
    changeIt($something);
    echo 
    $something// Outputs 6. 
    Hope that helps.
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  3. #3
    No. Phil.Roberts's Avatar
    Join Date
    May 2001
    Location
    Nottingham, UK
    Posts
    1,142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It indicates a variable passed by reference. rather than by value.

    http://uk2.php.net/manual/en/language.references.php


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •