note 112209 added to language.oop5.magic
| From: | danillo dot paiva dot toledo at gmail dot com | Date: | Thu, 16 May 2013 19:39:28 +0000 |
| Subject: | note 112209 added to language.oop5.magic | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-194832@lists.php.net to get a copy of this message | ||
While I was studying Ruby I saw as such interesting things as properties created + its getters and
setters in just one line.
I tryied to do the same in PHP and this is the code I have
class Father {
public function __call($name, $args) {
if(isset($this->$name)) {
if(isset($args[0]))
return $this->$name = $args[0];
return $this->$name;
}
return false;
}
}
class Child extends Father {
public $country = "Brazil";
public $state = "Sao Paulo";
}
Sometimes we don't need things like that on all classes but is quite interesting.
----
Server IP: 69.147.83.199
Probable Submitter: 186.204.90.201
----
Manual Page -- http://php.net/manual/en/language.oop5.magic.php
Edit -- https://master.php.net/note/edit/112209
Del: integrated -- https://master.php.net/note/delete/112209/integrated
Del: useless -- https://master.php.net/note/delete/112209/useless
Del: bad code -- https://master.php.net/note/delete/112209/bad+code
Del: spam -- https://master.php.net/note/delete/112209/spam
Del: non-english -- https://master.php.net/note/delete/112209/non-english
Del: in docs -- https://master.php.net/note/delete/112209/in+docs
Del: other reasons-- https://master.php.net/note/delete/112209
Reject -- https://master.php.net/note/reject/112209
Search -- https://master.php.net/manage/user-notes.php