0
在我的控制器上,我試圖找到以指定詞開頭的多行。在Codeingiter中顯示來自文件的錯誤消息
$file = file(FCPATH . 'application/logs/log-' . date('Y-m-d') . '.php');
$data['debug_messages'] = $this->display_lines($file, 'DEBUG');
$data['informational_messages'] = $this->display_lines($file, 'INFO');
和函數display_lines
function display_lines($file, $str) {
$lines = $file;
foreach ($lines as $lineNumber => $line) {
if (strpos($line, $str) !== false) {
return $line;
}
}
}
當我觀看出來把它僅顯示了每個的一行,併爲在圖像顯示不顯示多個信息和調試行
它應該顯示更多消息,但由於某種原因,每個消息只顯示一行。
問題如果有多個行與信息啓動,調試怎樣才能得到它返回的多行對每個信息和調試?
日誌文件
INFO - 2016-07-28 21:41:43 --> Config Class Initialized
INFO - 2016-07-28 21:41:43 --> Hooks Class Initialized
DEBUG - 2016-07-28 21:41:43 --> UTF-8 Support Enabled
INFO - 2016-07-28 21:41:43 --> Utf8 Class Initialized
INFO - 2016-07-28 21:41:43 --> URI Class Initialized
INFO - 2016-07-28 21:41:43 --> Router Class Initialized
INFO - 2016-07-28 21:41:44 --> Output Class Initialized
INFO - 2016-07-28 21:41:44 --> Security Class Initialized
DEBUG - 2016-07-28 21:41:44 --> Global POST, GET and COOKIE data sanitized
INFO - 2016-07-28 21:41:44 --> Input Class Initialized
INFO - 2016-07-28 21:41:44 --> Language Class Initialized
INFO - 2016-07-28 21:41:44 --> Loader Class Initialized
INFO - 2016-07-28 21:41:44 --> Helper loaded: form_helper
INFO - 2016-07-28 21:41:44 --> Helper loaded: url_helper
INFO - 2016-07-28 21:41:44 --> Database Driver Class Initialized
DEBUG - 2016-07-28 21:41:44 --> Encryption: Auto-configured driver 'openssl'.
查看
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="page-header">
<h4>Debug Messages</h4>
</div>
<textarea wrap="off" rows="15" readonly class="form-control"><?php echo $debug_messages; ?></textarea>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="page-header">
<h4>Informational Messages</h4>
</div>
<textarea wrap="off" rows="15" readonly class="form-control"><?php echo $informational_messages; ?></textarea>
</div>
</div>
</div>
這是在哪一行/函數返回錯誤陣列字符串轉換 – user4419336
? – Buksy
在我的視圖裏<?php echo $ informational_messages; ?>'和'<?php echo $ debug_messages; ?>我添加了我的視圖和日誌文件來提問。 – user4419336