- var_dump: documentation ( source)
- get_object_vars: documentation ( source)
<?php
// Everything you enter here will be executed by our servers. Try it!
class Example
{
public $publicSetting = 'public';
protected $protectedSetting = 'protected';
private $privateSetting = 'private';
public function showEverything()
{
return get_object_vars($this);
}
public function showMyPublicsOnly()
{
$analyse = function($object) {
return get_object_vars($object);
};
return $analyse($this);
}
}
$example = new Example();
var_dump(get_object_vars($example));
var_dump($example->showEverything());
var_dump($example->showMyPublicsOnly());