how can i check the value of a variable from a controller in codeigniter
<p>I am doing an upload image file in CodeIgniter. I want to trace out the image in my code and update my database path with it. I want to print the <code>$image_path</code> variable in the code below where it was located in my controller.</p>

<p>How can I print the <code>$image_path</code> variable to display or check its value inside the controller or maybe echo it out  ?</p>

<p>Here it is:</p>

<pre><code>&lt;?php
public function upload_file()
{
        $status = "";
        $msg = "";
        $file_element_name = 'userfile';

        if ($status != "error") {
                $config['upload_path'] = './assets/upimages/';
                $config['allowed_types'] = 'gif|jpg|png';
                $config['max_size'] = 1024 * 8;
                $config['encrypt_name'] = FALSE;
                $this-&gt;load-&gt;library('upload', $config);
                if (!$this-&gt;upload-&gt;do_upload($file_element_name))
                {
                        $status = 'error';
                        $msg = $this-&gt;upload-&gt;display_errors('', '');
                }
                else
                {
                        $data = $this-&gt;upload-&gt;data();
                        $image_path = $data['full_path'];
                        if(file_exists($image_path))
                        {
                                $status = "success";
                                $msg = "File successfully uploaded";
                        }
                        else
                        {
                                $status = "error";
                                $msg = "Something went wrong when saving the file, please try again.";
                        }
                }
                @unlink($_FILES[$file_element_name]);
        }
        echo json_encode(array('status' =&gt; $status, 'msg' =&gt; $msg));
}
?&gt;
</code></pre>