Getting PHP’s print_r Function To Return A String PHP’s print_r function is invaluable. It prints a human-readable string representation of a variable.