php debug error code example
Example: debug php
// ------ string -------
// use echo, exit for output
$a = 123
echo ($a);
exit;
// ------ array -------
$array = array(
1 => 'apple',
2 => 'banana',
)
// Method 1
echo "<pre>";
print_r($array);
echo "</pre>";
// Method 2
echo "<pre>";
var_dump($array);
echo "</pre>";
// Method 3 (no need exit) beacause of dd is already exit
dd($array)
// Method 4 (cakephp)
pr ($array);
// ------ json -------
$json = {"a":"123"}
pr (json_encode($json));
exit;
print_r (json_encode($json));
exit;