So, I would like to infer properties that are publicly available only within the class.
class MyClass
{
$public $var1, $var2, var3;
$private $pVar1, $pVar2, pVar3;
function outputPublic()
{
foreach($this as $key=>$val)
echo $key . ' : ' . $val . '<br>';
}
}
This works for me, using an external function to loop through the class instance, but I want to know how to do this from the inside. Is there a way to get an access modifier?
public property retrieval example
$obj = new MyClass();
foreach($obj as $key=$val)
echo $key . ' : ' . $val;
source
share