Função PHP print_r()
❮ Referência de Manipulação de Variáveis PHP
Exemplo
Imprima as informações sobre algumas variáveis de uma forma mais legível:
<?php
$a = array("red", "green", "blue");
print_r($a);
echo "<br>";
$b = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
print_r($b);
?>
Definição e uso
A função print_r() imprime as informações sobre uma variável de uma maneira mais legível.
Sintaxe
print_r(variable, return);
Valores de parâmetro
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 |
Detalhes técnicos
Valor de retorno: | Se a variável for integer, float ou string, o próprio valor será impresso. Se a variável for array ou objeto, esta função retornará chaves e elementos. Se o parâmetro de retorno estiver definido como TRUE, esta função retornará uma string |
---|---|
Tipo de retorno: | Verdadeiro ou String |
Versão do PHP: | 4.0+ |
❮ Referência de Manipulação de Variáveis PHP