2012-03-13 19 views
2

我的代碼工作正常在php 5.3.2-1在Ubuntu上。我最近將它移植到安裝了XAMPP的Windows中。它使用PHP 5.3.8。我收到錯誤。php 5.3.2-1代碼不工作在PHP 5.3.8

Non-static method Following::getUpdates() should not be called statically, assuming $this from incompatible context 

什麼是要走的路? 我是否應該更正我的代碼,以便在代碼中的每個位置替換聲明或
是否有辦法模擬舊的行爲(php 5.3.2和php.ini文件),因爲我不確定在我的系統中會拋出多少錯誤糾正它後面對。

UPDATE(代碼樣品)

public function actionIndex(){ 
     if(yii::app()->user->isGuest){ 
      $this->render('guestIndex'); 
     } 
     else{ 
      $dataProvider = Following::getUpdates(yii::app()->user->id); //genrerate data for the homepage of user i.e updates from followers 
      $this->render('userIndex',array('dataProvider'=>$dataProvider)); 
     } 


    } 

獲取誤差線$dataProvider = Following::getUpdates(yii::app()->user->id); 我使用Yii框架。

+0

告訴我們一個代碼示例 – soju 2012-03-13 12:48:51

+1

你在做$ this :: DoSomething()而不是MyObject :: DoSomething()嗎? – Hammerstein 2012-03-13 12:51:12

+0

我已經用靜態對象調用了一個非靜態函數。但是代碼在舊版本中工作正常。 – Terminal 2012-03-13 12:51:59

回答

7

您的新安裝很可能只包含E_STRICT警告,而您之前的安裝沒有。 Quoting the manual

調用非靜態方法會靜態生成E_STRICT級別警告。

這意味着你可以在你的error reporting禁用E_STRICT擺脫了警告,但IMO你應該可以解決問題的代碼。

+0

刪除E_STRICT工作。我想知道爲什麼它沒有在第一時間工作。我重新安裝了XAMPP,並且這次它工作。可能我上次必須與ini文件搞砸了。謝謝 – Terminal 2012-03-13 13:10:36

+0

我已經在一個地方使用了引用引用,這也被棄用了。「引用時間引用已被棄用」。除了返回值之外,還有其他工作嗎? – Terminal 2012-03-13 13:19:30

+0

@Terminal返回值聽起來像一個非常好,乾淨的想法imo,但看看http://stackoverflow.com/questions/1055812/how-to-avoid-call-time-pass-by-reference-deprecated -error-in-php – Gordon 2012-03-13 13:25:20