print_r() and var_dump() both show PHP values, but they optimize for different debugging needs.
Code examples
print_r($value);
var_dump($value);
print_r() is compact and readable for arrays. var_dump() includes types and lengths, which helps when debugging unexpected strings, booleans, and nulls.
Common errors
Do not leave raw debug output in production responses. It can reveal private data and break API output.
Related tool
Try the PHP print_r Formatter.