When I echo var_dump($_variable), I get one long, wrapping line with all varable\'s and values like
[\"kt_login_user\"]=> string(8) \"teacher1\" [\"kt_lo
For me the right answer was
echo '<pre>' . var_export($var, true) . '</pre>';
Since var_dump($var)
and var_export($var)
do not return a string, you have to use var_export($var, true)
to force var_export
to return the result as a value.
I usually have a nice function to handle output of an array, just to pretty it up a bit when debugging.
function pr($data)
{
echo "<pre>";
print_r($data); // or var_dump($data);
echo "</pre>";
}
Then just call it
pr($array);
Or if you have an editor like that saves snippets so you can access them quicker instead of creating a function for each project you build or each page that requires just a quick test.
For print_r
:
echo "<pre>", print_r($data, 1), "</pre>";
For var_dump()
:
echo "<pre>", var_dump($data), "</pre>";
I use the above with PHP Storm. I have set it as a pr
tab command.