本文整理汇总了PHP中Presenter::__get方法的典型用法代码示例。如果您正苦于以下问题:PHP Presenter::__get方法的具体用法?PHP Presenter::__get怎么用?PHP Presenter::__get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Presenter
的用法示例。
在下文中一共展示了Presenter::__get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __get
/**
* Getter
*
* @param string $name
* @return mixed
*/
public function __get($name)
{
//if linked
if (substr($name, 0, 6) == 'linked') {
return $this->_linked(substr($name, 6));
}
//else if formatted
if (substr($name, 0, 9) == 'formatted') {
return $this->_formatted(substr($name, 9));
}
//else get from parent as attribute
$result = parent::__get($name);
//if not in the parent as an attribute
if ($result === null) {
//check if it is a Ucfirst call for a property
$nName = preg_replace_callback('/^([A-Z])(\\S+)$/', function ($matches) {
return strtolower($matches[1]) . $matches[2];
}, $name);
//if so, get it
if ($name !== $nName) {
$result = ucfirst($this->{$nName});
}
}
//if not a Ucfirst call,
if ($result === null) {
//check if it is an UPPERCASE call
$nName = preg_replace_callback('/^([A-Z]+)$/', function ($matches) {
return strtolower($matches[1]);
}, $name);
//if so, get it
if ($name !== $nName) {
$result = strtoupper($this->{$nName});
}
}
//return the result whatever it is
return $result;
}