SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    I solve practical problems. bronze trophy
    Michael Morris's Avatar
    Join Date
    Jan 2008
    Location
    Knoxville TN
    Posts
    2,053
    Mentioned
    66 Post(s)
    Tagged
    0 Thread(s)

    Technically speaking, should magic __set return?

    Just a question that passed into my head - is the magic __set function supposed to return anything? Currently I don't - and the examples I've always seen don't. I throw an exception when the user tries an illegal set.

  2. #2
    SitePoint Guru Ruben K.'s Avatar
    Join Date
    Jun 2005
    Location
    Alkmaar, The Netherlands
    Posts
    693
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Conceptually speaking it should not return anything (other than $this, if you're into chaining) since it's a 'setter'

  3. #3
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,094
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    Shouldn't the setter return the value you assign, so you can do stuff like

    PHP Code:
    while ($row mysqli_fetch_assoc($res)) { ... } 
    i.e.

    PHP Code:
    function __set($name$value) {
      
    // blah
      
    return $value;

    ?
    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy


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
  •