本文整理匯總了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;
}