在我的CodeIgniter應用程序中,我在某些控制器中使用了會話類(並非全部都是這樣),並且我修復了在所有頁面中呈現的主題視圖。我想在視圖中使用session->setflash()
。因此,對於不使用會話的控制器,我必須檢查session->flashdata()
是否已設置或可用。我曾嘗試follwoing:當我試圖消息的建議CodeIgniter中對象方法的等效isset是什麼?
Fatal error: Cannot use isset() on the result of a function call (you can use "null !== func()" instead)
:
<?php if (isset($this->session->flashdata('msg'))):;?>
它返回以下錯誤
<?php if (null !== $this->session->flashdata('msg')):;?>
我得到了以下錯誤:
Fatal error: Call to a member function flashdata() on a non-object in...
旁邊的代碼點火器錯誤:
A PHP Error was encountered Severity: Notice
Message: Undefined property: CI_Loader::$session
Filename: themes/head.php
Line Number: 44