Just to add to John's answer, echo
should be the only one you use to print content to the page.
print
is slightly slower. var_dump()
and print_r()
should only be used to debug.
Also worth mentioning is that print_r()
and var_dump()
will echo by default, add a second argument to print_r()
at least that evaluates to true to get it to return instead, e.g. print_r($array, TRUE)
.
The difference between echoing and returning are: