class Util_Model
{
/**
* Get model property by property name chain.
* Usage: Util_Model::get_prop($order, 'item', 'name')
*/
public static function get_prop()
{
$obj = func_get_arg(0);
$props = array_slice(func_get_args(), 1);
if (!is_object($obj)) {
throw new \InvalidArgumentException('First parameter must be an object');
}
foreach ($props as $prop) {
if (preg_match('/^(.*)\(\)$/', $prop, $matches)) {
$obj = call_user_func(array($obj, $matches[1]));
} else {
$obj = $obj->{$prop};
}
if (!is_object($obj)) {
break;
}
}
return is_object($obj) ? (string)$obj : $obj;
}
}
$obj->{$prop} i wonder the meaning of this line, why there is a brace here? and why there is no error when {$prop} is null.if you don't understand my question, leave something I will amend it.thanks!