Reputation: 81721
As I understand, when you define __get and __set functions in php, the way of reaching attributes don't change. I mean
class something {
public $world;
public $hello;
public function __get($name) {
return $this - > $name;
}
public function _set($name, $value) {
$this - > $name = $value;
}
}
Now I am wondering what I am gonna do if I don't want $hello
to call __get
and __set
functions implicitly when I reach it, only for $world
;
What I want is would look like this one in C#
class something {
public string world;
public string hello{get;set;}
}
Thanks...
Upvotes: 1
Views: 157
Reputation:
Any unaccessible properties will automatically call __get
and __set
, therefore, set $world
to private
.
Upvotes: 4