2011-09-09 22 views
-3

以下代碼有什麼問題?沒有笑臉功能它可以工作,並與$ tz =笑臉($ this-> text);沒有。未能插入一行

我試圖把顯示錯誤,但.. MHMM不通過將合適的函數調用工程.. 0錯誤

ini_set('display_errors',1); 
error_reporting(E_ALL); 


<?php 
class ChatLine extends ChatBase 
{ 
    protected $text = '', $author = '', $gravatar = ''; 
    public function save() 
    { 
     $tz = smiley($this->text); 

     DB::query(" 
      INSERT INTO webchat_lines (author, gravatar, text) 
      VALUES (
       '".DB::esc($this->author)."', 
       '".DB::esc($this->gravatar)."', 
       '".$tz."' 
     )"); 

     // Returns the MySQLi object of the DB class 
     return DB::getMySQLiObject(); 
    } 

    public function smiley($text) 
    { 
     $privatesmilies = array(
      ":)" => "smile1.gif", 
      ";)" => "wink.gif" 
     ); 

     reset($privatesmilies); 
     while (list($code, $url) = each($privatesmilies)) 
      $text = str_replace($code, "<img src=http://127.0.0.1/chat/img/$url align=absmiddle/>", $text); 

     return $text; 
    } 
} 
?> 
+1

嘗試$ tz = $ this->笑臉($ this-> text); – ajacian81

+0

非常感謝! :) –

+1

這個蘋果有什麼問題沒人能看到?請解釋**爲什麼**不起作用。 – Bojangles

回答

2

您啓用了錯誤報告...外的PHP代碼塊!取而代之的是:

ini_set('display_errors',1); 
error_reporting(E_ALL); 

<?php 
// ... 
?> 

...這樣做:

<?php 
ini_set('display_errors',1); 
error_reporting(E_ALL); 

// ... 
?> 

然後PHP會告訴你,沒有一個叫smiley()功能。然而,有一種分類方法:$this->smiley()

+0

當我發佈整個代碼時,我刪除了報告錯誤。 –