我正在做一個東西在PHP中,而不是它的調試模式。所以我我們php錯誤報告未初始化的字符串偏移量:0
error_reporting(E_ALL);
但是當我試圖訪問字符串的任何字符它給我的錯誤是由於錯誤報告。
$sentence = "Hello World";
$sentence[0] //Uninitialized string offset: 0
編輯:
public static function prepareSentence($sentence)
{
$sentence = trim($sentence);
if ($sentence[0] == '"') //Uninitialized string offset: 0
$sentence = substr($sentence, 1, strlen($sentence));
if ($sentence[strlen($sentence) - 1] == '"')
$sentence = substr($sentence, 0, -1);
if ($sentence[0] == '"' || $sentence[strlen($sentence) - 1] == '"')
return self::prepareSentence($sentence);
return $sentence;
}
我應該如何才能在開發模式下工作要做。我需要error_reporting(E_ALL);
在此先感謝。
多一點的代碼會很好。你以前使用過句子變量嗎? – 2012-02-04 05:34:25
好男人。我剛剛編輯。 – Elbek 2012-02-04 05:36:21
運行得很好:http://ideone.com/R6y3n – mpen 2012-02-04 05:40:34