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>");
}
Choosing the right ecommerce platform can make or break your online business. But is Shopify…
Most "AI agent" content online is still stuck at the demo stage — a slick…
If you've been using Claude Code as little more than a fancy autocomplete — typing…
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…