Using the HTML pre tags in PHP

USING THE HTML <PRE></PRE> TAGS IN PHP

I use <pre></pre> tags around debug output for readability purposes. To show you how much more readable the data is when using the tags, I'll give an example:

EXAMPLE:

After setting up a basic Bootstrap form, I used the <pre></pre> tags around the var_dump() function to display data from the form inputs. I initially filled out the info with dummy information to output some data in the array from the form.

PHP code using pre tags and var_dump

This results in the following output. Notice how readable it is:

Image of a sample form with an output of dummy data in an array

This is compared to not using the <pre></pre> tags, which results in unreadable code like this:

Image of a sample form with an output of dummy data in an array

So the bottom line is, <pre></pre> are great to use around debug output for readable code!





<< BACK