While debugging php code we might need to use print_r() or var_dump() functions with exit or die, as in following code but by following code page will not render completely because exit or die stop remaining code from execution. If we don’t use die or exit then page design will break.
echo '<pre>'; print_r($debug_array); echo '</pre>'; exit; |
But we can also show debug output in browser console and page render completely without any break at same time. To do so following code will help to show output in browser console.
if(is_array($data) || is_object($data))
{
echo("<script>console.log('".json_encode($data)."');</script>");
} else {
echo("<script>console.log('".$data."');</script>");
}
When building real-world Laravel applications, email handling quickly becomes scattered. You send emails from controllers,…
Build flexible, readable, and secure query filters across multiple Laravel models — no more bloated…
Artificial Intelligence is transforming how we work, create, and earn. But most people get stuck…
In today’s fast-paced world, businesses can no longer rely solely on traditional methods to stay…
Add an Addon Domain in GoDaddy with Web Hosting Deluxe (Step-by-Step Guide). If you are…
The ability to create reliable APIs is essential in today's web development environment. I'll show…