php - codeigniter 错误日志文件仅显示通知错误但错误消息未显示在屏幕上

标签 php codeigniter logging error-handling reference

我真的被这个问题吓坏了,它开始推迟我项目的其余部分,这真的让我很沮丧。

要点是它只向我显示通知错误和错误日志文件中的 404 错误不在屏幕上,其他通知错误显示在屏幕上。

为什么 codeigniter 会在应用程序/日志中显示错误,例如:

    ERROR - 2015-04-18 12:03:24 --> 404 Page Not Found --> uploaded_img

    ERROR - 2015-04-18 12:03:24 --> 404 Page Not Found --> images

    ERROR - 2015-04-18 12:03:24 --> 404 Page Not Found --> images

// Above all three errors are shows only when i visit home page of my website and I am not calling any type of images class

    ERROR - 2015-04-18 11:30:14 --> Severity: Notice  --> Trying to get property of non-object D:\wamp\www\mywebsite\application\views\product_detail.php 2

    ERROR - 2015-04-18 11:30:14 --> Severity: Notice  --> Trying to get property of non-object D:\wamp\www\mywebsite\application\views\product_detail.php 3

   ERROR - 2015-04-18 11:30:14 --> Severity: Notice  --> Trying to get property of non-object D:\wamp\www\mywebsite\application\views\product_detail.php 4

// Above all three errors are shown when i view product_detail.php page of my website.

我的 index.php 设置在:

error_reporting(E_ALL | E_STRICT)

和配置:

$config['log_threshold'] = 1;

这是我的产品 Controller 类代码:

class Product extends Frontend_Controller{

public function __construct(){
    parent::__construct();
    $this->load->model('product_m');
    $this->load->library('cart');
}

public function index($str){
    // fetch the article
    $this->data['product_info'] = $this->product_m->get_product_detail($str);

    // creating breadcrumb navigation path
    $this->data['main_category'] = $this->uri->segment(1);
    $this->data['sub_category'] = $this->uri->segment(2);
    $this->data['current_location'] = str_replace('-', ' ',str_replace('.html', '', $this->uri->segment(3))); 

    // load view
    $this->load->view('product_detail',$this->data);
}

当我做var_dump($this->data['product_info']);

object(stdClass)[18]
  public 'id' => string '24' (length=2)
  public 'parent_category' => string 'sweets' (length=6)
  public 'child_category' => string 'chikki-sweets' (length=13)
  public 'product_url' => string 'chikki-bom-bom.html' (length=19)
  public 'product_name' => string 'Chikki Bom Bom' (length=14)
  public 'product_desc' => string '<span style="font-weight: bold; font-size: 24px; font-family: Sans;">Chikki Bom Bom </span><span style="font-weight: bold; font-size: 24px; font-family: Verdana;">Chikki</span><span style="font-weight: bold; font-size: 24px; font-family: Sans;"> </span><span style="font-weight: bold; font-size: 24px; font-family: 'Comic Sans MS';">Bom Bom.</span><div><span style="font-family: 'Comic Sans MS'; font-size: 24px; font-weight: bold; line-height: 34.2857170104981px;"><br></span></div><div><pre><span style="font-f'... (length=1161)
  public 'product_sku' => string '123456789012' (length=12)
  public 'quantity' => string '23' (length=2)
  public 'price' => string '400.00' (length=6)
  public 'offer_price' => string '100.00' (length=6)
  public 'product_date' => string '2015-03-13' (length=10)
  public 'img_url_1' => string 'http://localhost/my_website/uploaded_img/chiki-boom-boom_1.png' (length=63)
  public 'img_url_2' => string 'http://localhost/my_website/uploaded_img/chikki_baadam_1.jpg' (length=61)
  public 'img_url_3' => string 'http://localhost/my_website/uploaded_img/white-rasbhari_1.jpg' (length=62)
  public 'img_url_4' => string 'http://localhost/my_website/uploaded_img/rasgulla_1.jpg' (length=56)
  public 'img_url_5' => null

这是我的 product_detail.php 代码,其中显示错误:

$total_product = (int) $product_info->quantity; // line number 2
$mrp_price = (int) $product_info->price; // line number 3
$offer_price = (int) $product_info->offer_price; // line number 4

这里我在 product_detail.php 页面上做了var_dump($product_info);:

object(stdClass)[18]
 public 'id' => string '24' (length=2)
 public 'parent_category' => string 'sweets' (length=6)
 public 'child_category' => string 'chikki-sweets' (length=13)
 public 'product_url' => string 'chikki-bom-bom.html' (length=19)
 public 'product_name' => string 'Chikki Bom Bom' (length=14)
 public 'product_desc' => string '<span style="font-weight: bold; font-size: 24px; font-family: Sans;">Chikki Bom Bom </span><span style="font-weight: bold; font-size: 24px; font-family: Verdana;">Chikki</span><span style="font-weight: bold; font-size: 24px; font-family: Sans;"> </span><span style="font-weight: bold; font-size: 24px; font-family: 'Comic Sans MS';">Bom Bom.</span><div><span style="font-family: 'Comic Sans MS'; font-size: 24px; font-weight: bold; line-height: 34.2857170104981px;"><br></span></div><div><pre><span style="font-f'... (length=1161)
 public 'product_sku' => string '123456789012' (length=12)
 public 'quantity' => string '23' (length=2)
 public 'price' => string '400.00' (length=6)
 public 'offer_price' => string '100.00' (length=6)
 public 'product_date' => string '2015-03-13' (length=10)
 public 'img_url_1' => string 'http://localhost/my_website/uploaded_img/chiki-boom-boom_1.png' (length=63)
 public 'img_url_2' => string 'http://localhost/my_website/uploaded_img/chikki_baadam_1.jpg' (length=61)
 public 'img_url_3' => string 'http://localhost/my_website/uploaded_img/white-rasbhari_1.jpg' (length=62)
 public 'img_url_4' => string 'http://localhost/my_website/uploaded_img/rasgulla_1.jpg' (length=56)
 public 'img_url_5' => null

我应该怎么做才能消除这些错误?

最佳答案

删除 semi colon 是一个语法错误。设置

$config['log_threshold'] = 0;

关于php - codeigniter 错误日志文件仅显示通知错误但错误消息未显示在屏幕上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29716273/

相关文章:

php - Laravel 如何更新一对一关系?

php - 如何将 $_SERVER 变量注入(inject)到服务中

c++ - 无法针对 OS X 上的 Boost.log 进行编译

php - 获取 ./doctrine orm :run-dql to work with the sandbox

php - 如何使具有许多左连接的 mysql 查询执行得更快?

javascript - 发送多个内容类型 Ajax

php - 有人知道任何好的 PHP Codeigniter 自动表单生成器吗?

php - Codeigniter session 数据,它们只是 cookie 吗?

powershell - 如何使用 foreach-object 并行将日志写入单个文件?

logging - 命名记录器的 log4net 策略?