- property_exists: documentation ( source)
<?php
trait ProtectedTestTrait {
protected $test;
}
class ProtectedTestBase {
use ProtectedTestTrait;
}
class ProtectedTestChild {
public function execute()
{
return property_exists($this, 'test');
}
}
$protectedChild = new ProtectedTestChild();
echo $protectedChild->execute() ? 'ja' : 'nee';