[英]Getter method cannot access its own property
我有以下具有屬性float $price
實體模型。
當我創建這樣的getter方法時:
public function _getPrice()
{
return $this->price*100;
}
它一直給我以下錯誤:
未定義的屬性:App \\ Model \\ Entity \\ Model :: $ price
有什么問題?
您實際上是在嘗試從自身內部訪問getter方法。
為了使它起作用,請嘗試按以下方式重寫它:
public function _getPrice()
{
return $this->_properties['price'] * 100;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.