【问题标题】:codeigniter error log file only shows notice error but error msg not shows on screencodeigniter 错误日志文件仅显示通知错误,但错误消息未显示在屏幕上
【发布时间】:2015-06-25 07:30:00
【问题描述】:

我一直在用这个来拔掉我的头发,它开始推迟我的项目的其余部分,这真的让我很沮丧。

主要的一点是它只显示一个通知错误和 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;

这是我的产品控制器类代码:

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

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

【问题讨论】:

  • 你最好从 product_detail.php 发布一些代码
  • 现在我添加了代码,请再检查一遍

标签: php codeigniter logging error-handling reference


【解决方案1】:

设置

ini_set('display_errors', 1);

并确保在 index.php 文件中将 ENVIRONMENT 设置为:

define('ENVIRONMENT', 'development');

将 error_reporting 设置为 E_ALL。

【讨论】:

  • codeigniter 向我显示所有 php 错误,但它不仅显示错误日志文件中记录的这些错误...
【解决方案2】:

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

$config['log_threshold'] = 0;

【讨论】:

  • 不,它没有获取关联数组兄弟它的返回对象..等待我发布 var_dump($this->data['product_info']); 的快照;
  • 兄弟我发布了 var_dump($this->data['product_info']); 的结果请立即检查
  • @shawn_parker 在stackoverflow.com/questions/16909830/…之后结帐
  • 不,它不工作。兄弟记住,错误不会显示在屏幕上,但如果从任何行中删除分号,则会在屏幕上显示错误。
  • 我看不到这个问题的解决方案。我正在搜索过去 5 小时的解决方案
猜你喜欢
  • 2012-01-31
  • 2013-12-31
  • 1970-01-01
  • 2012-08-23
  • 2020-01-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多