Menu Home

print_r

osbo.com | PHP | Functions | print_r

Prints human-readable information about a variable

Syntax

print_r ( mixed $expression [, bool $return = FALSE ] ) : mixed

Parameters

expression

The expression to be printed.

return

If you would like to capture the output of print_r(), use the return parameter. When this parameter is set to TRUE, print_r() will return the information rather than print it.

Return

If given a string, integer or float, the value itself will be printed. If given an array, values will be presented in a format that shows keys and elements. Similar notation is used for objects. When the return parameter is TRUE, this function will return a string. Otherwise, the return value is TRUE.

Examples

expression | bool


			
			
		

expression | int

0

expression | float

0

expression | string

0

expression | array

Array
(
    [0] => 0
    [1] => 1
    [2] => Array
        (
            [0] => 0
            [1] => 1
        )

)

expression | object | standard class

stdClass Object
(
    [var] => 0
)

expression | object | custom class

myclass Object
(
    [var] => 0
)

return | false

myclass Object
(
    [var] => 0
)
output: 
1

return | true

output: 
myclass Object
(
    [var] => 0
)

Internal

var_dump

var_export

External

PHP