SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot DocDave's Avatar
    Join Date
    Sep 2004
    Location
    Milwaukee, WI, USA
    Posts
    113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Ampersand before function

    I know this is probably something fairly simple, but I have not seen it before. What is the difference between:
    PHP Code:
    function &somefunc()
    {... 
    and
    PHP Code:
    function somefunc()
    {... 
    I see it again when the function is called:
    PHP Code:
    $instance =& somefunc(); 
    Specifically what does the ampersand do?

    Thanks
    .:Blog:.

  2. #2
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  3. #3
    SitePoint Member
    Join Date
    Dec 2010
    Location
    Silicon Valley
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's a good thing to know what passing by reference is and how to use it properly. You're bound to run into it sooner or later.

    I would avoid using passing by reference as it may lead to unexpected results. Here's a good article on it: http://schlueters.de/blog/archives/1...d-foreach.html


Tags for this Thread

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
  •