我正在將舊版本的codeigniter升級到新版本,但在升級過程中出現「無法訪問受保護的屬性CI_Output :: enable_profiler」錯誤。我知道屬性enable_profiler已經在新版本中受到保護。但我不知道如何在控制器/模型中訪問此屬性。我不想改變我現有的代碼。以下是我的代碼無法訪問受保護的屬性CI_Output :: enable_profiler
if($this->output->enable_profiler)
{
.......
}
我正在將舊版本的codeigniter升級到新版本,但在升級過程中出現「無法訪問受保護的屬性CI_Output :: enable_profiler」錯誤。我知道屬性enable_profiler已經在新版本中受到保護。但我不知道如何在控制器/模型中訪問此屬性。我不想改變我現有的代碼。以下是我的代碼無法訪問受保護的屬性CI_Output :: enable_profiler
if($this->output->enable_profiler)
{
.......
}
請仔細閱讀您可以使用下面的方法來啓用禁用分析的CI DOC
$this->output->enable_profiler(TRUE);// to enable
$this->output->enable_profiler(FALSE); // to disable
的返回類型爲void爲$this->output->enable_profiler(FALSE);
在class CI_Output
/**
* Enable/disable Profiler
*
* @access public
* @param bool
* @return void
*/
function enable_profiler($val = TRUE)
{
$this->enable_profiler = (is_bool($val)) ? $val : TRUE;
return $this;
}
我不想啓用或禁用分析器。我想檢查探查器是啓用還是禁用。 $ this-> output-> enable_profiler屬性返回true或false來表明探查器已啓用或已禁用。 – aishazafar