In this article, you will learn how to get the information about a variable in PHP. The PHP print_r() function prints the information about a variable in a more human-readable way.
what is the syntax of the PRINT_R() function in php?
print_r(variable, return);
Parameter | Description |
---|---|
variable | Required. Specifies the variable to return information about |
return | Optional. When set to true, this function will return the information (not print it). Default is false |
examples of the PRINT_R() function
Example 1. In this example, we print the information about some variables in a more human-readable way.
<?php
$a = array("red", "green", "blue");
print_r($a);
echo "<br>";
$b = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
print_r($b);
?>