SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru D-flyer's Avatar
    Join Date
    Jan 2001
    Location
    Near a computer
    Posts
    782
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $test = new TestClass(); or $test = &new TestClass();

    $test = new TestClass(); or $test = &new TestClass();

    which should one use and why???

    Or is this wrong???

    Learning Classes in babysteps

    Thanks in advance

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,174
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)

    passing vars by reference

    the ampersand prefix is used to pass a variable by reference. from the PHP docs Chapter 14. References Explained

    "You can pass variable to function by reference, so that function could modify its arguments."

    "Following things can be passed by reference:
    Variable, i.e. foo($a)
    New statement, i.e. foo(new foobar())
    Reference, returned from a function."

    "Any other expression should not be passed by reference, as the result is undefined."


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
  •