Hi Tyson,

I was taught in school that trailing zeros and the decimal point can be
omitted when writing a number. It reads much better when you don't have to
see all the zeroes following the decimal point. When humans write a number
that has no digits after the decimal point they don't write the decimal
point. `print_r` is designed to print the data in a human-readable format.
There should be no information about the variable type. If you would like
to see the data together with the type then you can use `var_dump`. If you
want to see the data exactly as it is stored internally then use
`var_export`.
`print_r` is meant to display the data recursively in a friendly way.
Adding the unnecessary decimal point is against that.

On a technical note. `print_r` and `print` display data after casting it to
a string. The way PHP is currently designed is that when you cast 1.0 to a
string it becomes "1". Same with boolean TRUE. If you want to change the
way that floats and booleans are represented as strings then you would have
to change the way that the cast to string works. This would be a major
change.

Kind Regards,
Kamil

Reply via email to