2014-02-23 19 views
0

我已經升級我的WordPress網站,並獲得在頭警告,我是新手在PHP,但發現答案由count更換strlen,然後我得到一個警告用count替換strlen新警告如何重寫函數正確?

function head() { 
    if (strlen ($this->description) > 0) { 
    // if (count ($this->description) > 0) { 
     if (function_exists ('mb_substr')) 
      $description = mb_substr (strip_tags ($this->description), 0, $this->max_length); 
     else 
      $description = substr (strip_tags ($this->description), 0, $this->max_length); 
     $description = trim (preg_replace ("/[\r\n ]+/", ' ', $description)); 
     $description = HeadSpace_Plugin::specialchars ($description); 

     echo '<meta name="description" content="'.$description.'" />'."\r\n"; 
    } 
} 

有人可以幫我改寫這個功能嗎?謝謝

+0

發佈您獲得的完整警告。 – Rikesh

回答

0

你有沒有試過?

if (strlen($this->description) > 0) { 
     if (function_exists ('mb_substr')) 
      $description = mb_substr (strip_tags ($this->description), 0, $this->max_length); 
     else 
      $description = substr (strip_tags ($this->description), 0, $this->max_length); 

     $description = trim (preg_replace ("/[\r\n ]+/", ' ', $description)); 
     $description = HeadSpace_Plugin::specialchars ($description); 

     echo '<meta name="description" content="'.$description.'" />'."\r\n"; 
    } 
+0

你可以發佈你收到的警告嗎? – 2014-02-23 13:32:11

相關問題