View Single Post

  #3 (permalink)  
Old 12-12-2007
Steve
 
Posts: n/a
Default Re: __set() TRUE/FALSE


"turnitup" <same@same> wrote in message
news:4760199b$0$13940$fa0fcedb@news.zen.co.uk...
> What is the easiest way of testing whether a call to __set() has been
> successful?
>
> At the moment doing
>
> $success = ($foo->bar = "fred");
> echo $success
>
> returns "fred", even though the __set function returns TRUE.
>
> Any thoughts?


whatever happens to or during $foo->bar being set, you are doing a double
assignment...two variables being given the same assignment. 'fred' is NOT
being piped to $success through $foo. further, if bar is a *defined*
interface of $foo, __set() will NEVER be called. __set() is meant to handle
*undefined* interfaces the caller is trying to use...a good place to say,
'invalid property accessed'.


Reply With Quote