Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the meaning of _r in PHP's print_r()?

Tags:

php

I've seen this answer on so, but i'm not sure if it's the same for PHP... and if it is, what is the meaning of reentrant ?

like image 679
Jean Avatar asked Mar 03 '14 20:03

Jean


4 Answers

From PHP.net:

print_r — Prints human-readable information about a variable

so the answer is "readable"

like image 147
Jason OOO Avatar answered Oct 21 '22 16:10

Jason OOO


From the PHP manual:

print_r — Prints human-readable information about a variable

The point of print_r is that it prints infos about a variable in a human-readable way, as opposed to var_dump, for instance...

So a good guess is that the r stands for readable.

like image 44
Macmade Avatar answered Oct 21 '22 16:10

Macmade


print_r will return any output is produces on the screen and produce a human readable format of an object

<?php
    $a = array ('a' => 'apple', 'b' => 'banana', 'c' => array ('x', 'y', 'z'));
    print_r ($a);
?>

Will output

Array
(
    [a] => apple
    [b] => banana
    [c] => Array
        (
            [0] => x
            [1] => y
            [2] => z
        )
)
like image 35
Krimson Avatar answered Oct 21 '22 17:10

Krimson


The _r stands for readable. This is visible when you display arrays in PHP. It shows a nice identation while doing so.

like image 41
Visakh Vijayan Avatar answered Oct 21 '22 17:10

Visakh Vijayan