2

What is my problem is I using php version 5.4 will have this error in MY_Controllar, kindly take a look the screenshot as below

enter image description here

but there are not problem below php version 5.3

here is my code

 <?php

class MY_Controller extends CI_Controller {

    function __construct()
    {
        parent::__construct();
        $data->the_leave_data = $this->leave_data(); <--- line 8 is here
        $this->the_leave_data = $data->the_leave_data;
        $this->load->vars($data);
    }

    function leave_data()
    {
        $data = array();
        $this->load->model('leave_data_model');
        $staff_id = $this->session->userdata('staff_id');
        if($query = $this->leave_data_model->get_by('staff_id',$staff_id))
        {
            $data['leave_data_records'] = $query;           
        }
        var_dump($data);
        return $data;
    }

}

?>

here is the var_dump return value from $data

leave_data_records' => 
object(stdClass)[21]
  public 'leave_data_id' => string '1' (length=1)
  public 'staff_id' => string '1' (length=1)
  public 'annual_leave' => string '1.0' (length=3)
  public 'sick_leave' => string '0.0' (length=3)
  public 'annual_leave_balance' => string '0.0' (length=3)
  public 'sick_leave_balance' => string '0.0' (length=3)
  public 'year' => string '2012' (length=4)

Any Idea how to solve it? Thanks

2
  • this is likely to be a deprecation bug in CodeIgniter, please report this to them directly Commented Jan 23, 2013 at 9:45
  • Any solution for this yet? From what I gather this seems to be only a problem with newer versions of php. Everything seems to work fine, still annoying to have this error pop up everywhere though. I guess I'll just turn down the error reporting for now ... Commented May 15, 2013 at 17:04

2 Answers 2

5

are you using PHP 5.4? PHP 5.4 has strict standards. You need to declare $data as an object of stdClass:

$data = new stdClass();    
$data->the_leave_data = $this->leave_data();
Sign up to request clarification or add additional context in comments.

Comments

0

Means that $this->leave_data(); is empty.

I don't see no where, to be loaded with data inside your controller. If you define it somewhere else end it's loaded from within CI_Controller... you should do parent::$this->leave_data();

4 Comments

Hi w0rldart, thanks for reply, I got var_dump the $data, it's got return value, but it's still got the error
so you're saying that var_dump($data); after de eight line, outputs values?
ya, I had update my post, kindly take a look the return value in var_dump
Have tied using $data as an array, instead of an object?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.