note 111360 added to function.get-object-vars
| From: | at chozilla | Date: | Mon, 11 Feb 2013 12:35:03 +0000 |
| Subject: | note 111360 added to function.get-object-vars | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-193603@lists.php.net to get a copy of this message | ||
A simple way to call this function within an Object and to only export the *public* params would be
to artificially change the scope - for example with a closure in php 5.3:
class Example
{
public $publicSetting = 'public';
protected $protectedSetting = 'protected';
private $privateSetting = 'private';
public function showEverything()
{
return get_object_vars($this);
}
public function showMyPublicsOnly()
{
$me = $this;
$publics = function() use ($me) {
return get_object_vars($me);
};
return $publics();
}
}
----
Server IP: 69.147.83.199
Probable Submitter: 87.139.246.43
----
Manual Page -- http://php.net/manual/en/function.get-object-vars.php
Edit -- https://master.php.net/note/edit/111360
Del: integrated -- https://master.php.net/note/delete/111360/integrated
Del: useless -- https://master.php.net/note/delete/111360/useless
Del: bad code -- https://master.php.net/note/delete/111360/bad+code
Del: spam -- https://master.php.net/note/delete/111360/spam
Del: non-english -- https://master.php.net/note/delete/111360/non-english
Del: in docs -- https://master.php.net/note/delete/111360/in+docs
Del: other reasons-- https://master.php.net/note/delete/111360
Reject -- https://master.php.net/note/reject/111360
Search -- https://master.php.net/manage/user-notes.php