- property_exists: documentation ( source)
- var_dump: documentation ( source)
<?php
trait AccessibleProperties
{
public function __isset($property)
{
return property_exists($this, $property);
}
public function __get($property)
{
if (property_exists($this, $property)) {
return $this->$property;
}
}
}
class Fooba {
use AccessibleProperties;
protected $a = 'Some value';
}
$foo = new Fooba;
var_dump($foo->a);
var_dump(isset($foo->a));