tôi đang làm một công cụ trong php và không phải là chế độ gỡ lỗi. Vì vậy, tôi là chúng tôibáo cáo lỗi php Uninitialized chuỗi offset: 0
error_reporting(E_ALL);
nhưng khi tôi cố truy cập bất kỳ ký tự nào của chuỗi, nó cho tôi lỗi do báo cáo lỗi.
$sentence = "Hello World";
$sentence[0] //Uninitialized string offset: 0
chỉnh sửa:
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;
}
Làm thế nào tôi nên làm để làm việc trong chế độ dev. Tôi cần error_reporting (E_ALL);
cảm ơn trước.
mã nhỏ hơn sẽ đẹp hơn. Bạn có sử dụng biến câu trước không? –
Chắc chắn là người đàn ông. Tôi vừa chỉnh sửa. – Elbek
chỉ chạy tốt: http://ideone.com/R6y3n – mpen