我正在做一个东西在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