CodeIgniter Forums
var_dump question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: General (https://forum.codeigniter.com/forumdisplay.php?fid=1)
+--- Forum: Regional User Groups (https://forum.codeigniter.com/forumdisplay.php?fid=25)
+--- Thread: var_dump question (/showthread.php?tid=69066)



var_dump question - Germanikus - 10-03-2017

Hello,
how and where I build the var_dump, which after a click on a button shows the content of an input on the selected viewers.
so, do I have to install that in the model or the controller?


RE: var_dump question - frankenestain - 10-04-2017

(10-03-2017, 01:09 PM)Germanikus Wrote: Hello,
how and where I build the var_dump, which after a click on a button shows the content of an input on the selected viewers.
so, do I have to install that in the model or the controller?

I think Preferably in controller immediately after the data statement 

Code:
var_dump($data);



RE: var_dump question - InsiteFX - 10-04-2017

var_dump is a php method for viewing objects and arrays etc;

var_dump() - Dumps information about a variable.


SEE: PHP.NET = var_dump()

Here is an CodeIgniter Helper method to do formatted output:


PHP Code:
/**
 * varDebug () - Add this method to a CodeIgniter Helper.
 * -----------------------------------------------------------------------
 *
 * Formatted output of var_dump() etc;
 */
if ( ! function_exists('varDebug'))
{
    
/**
     * Debug Helper
     * -------------------------------------------------------------------
     * Outputs the given variable(s) with color formatting and location
     *
     * @param    mixed    - variables to be output
     */
    
function varDebug()
    {
        list(
$callee) = debug_backtrace();

        
$arguments func_get_args();

        
$total_arguments func_num_args();

        echo 
'<div><fieldset style="background: #fefefe !important; border:1px red solid; padding:15px">';
        echo 
'<legend style="background:lightgrey; padding:5px;">'.$callee['file'].' @line: '.$callee['line'].'</legend><pre><code>';

        
$i 0;
        foreach (
$arguments as $argument)
        {
            echo 
'<strong>Debug #'.++$i.' of '.$total_arguments.'</strong>: '.'<br>';
            
var_dump($argument);
        }

        echo 
"</code></pre></fieldset><div><br>";
        exit;
    }
}

Hope that helps