Set and string concatenation?

You should add a __get() method that allows you to access inaccessable properties just as you did with __set(). You could then do the following.

You should add a __get() method that allows you to access inaccessable properties just as you did with __set(). You could then do the following: $view->myvar = $view->myvar. 'Added text.'; The __get() method would be: public function __get($var) { return (isset($this->data$var))?

$this->data$var: ''; }.

Yeah, I saw this after editing my post. – clinisbut Sep 13 '10 at 21:24 I must have dropped this in right as you were editing it. – Mitch C Sep 13 '10 at 21:29 On a side note: returning NULL rather then an empty string seems more appropriate.

– Wrikken Sep 14 '10 at 0:26.

FYI, for simple assignment, magic methods aren't even necessary. Class A { } $a = new A(); $a->str = '1'; $a->str . = '2'; echo $a->str; // outputs 12 This will work just fine as PHP will create the new properties through assignment.

__set/get usually is used when additional checks/code need to be run on the values.

I need magic method here because I is a MUST to store the data inside $data member. – clinisbut Sep 14 '10 at 5:52.

It's because __set() is a method and not a string. If you want it to "act" like a string you can change it to this. Class View { private $data; public function __set( $key, $value ) { if (empty($this->data$key)) { $this->data$key = $value; } else { $this->data$key .

= $value; } } }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions