Hey dude, today we are going to understand about Laravel print_r, var_dump and dd, all are very helpful in terms of debugging in Laravel.
To figure out the error we always trying to view the variables. With Laravel, we can use dd() ( a combination of the dump and die ) to debug the program.
Why we need to use Laravel var_dump (), when we have print_r (), dd(), dump() and die() for debugging.
Well, Let’s assume,
We want to know the data type of the variable with value at some point of debugging. Then we can use var_dump($variable) it will return something like this
(int) 5 (string) ‘testcase’
I don’t recommend to use var_dump() to view the Laravel collection. Because we have amazing methods print_r() and dd() for that.
You don’t need to use var_dump() unless you want to see the data type of the variable.
With dd(), We have to expand the object and then we can see a different level of data in the object.
We can use CTRL+Click on windows and CMD+click on mac to expand all data at once.
To avoid this limitation we can use print_r() which give us a nice expanded array.
Even we can use pre HTML tag to prettify the array data.
We can also use toArray() helper function to convert Laravel collection into an array.
Today we are going to learn about managing multiple PHP versions on ubuntu with xampp.…
Let's understand about how to use coding to improve your website's SEO. In today’s computerized…
Let's understand the most important linux commands for web developers. Linux, as an open-source and…
Today we are going to discuss top 75+ Laravel interview questions asked by top MNCs.Laravel,…
Today we will discuss about the Mailtrap integration with laravel 10 .Sending and receiving emails…
Today we are going to integrate FCM (Firebase Cloud Messaging) push notifications with ionic application.Firebase…