15 1 0 4000 1 https://codeblock.co.za 300 true 0
theme-sticky-logo-alt

print_r()

0 Comments

Programming Language

PHP [Versions: 4, 5, 7, 8]

Syntax

Typical Usage

Displays human-readable information about a variable in PHP.

Accepted Parameters

  • value (mixed) (Required): The value or expression you wish to print.
  • return (boolean) (Optional) (Default = false): If set to true, the expression will be returned rather than printed.

Return Value(s)

If the output is a string, integer or float, the value will be printed. If the output is an array or object, values will be presented in a format that shows keys and elements/values.

Notes

When the return parameter is used, the print_r() function uses internal output buffering so it cannot be used inside an ob_start() callback function.

Examples of print_r()

Example 1

$data = array (
     'item 1',
     'item 2',
     'item 3',
 );
 print_r($data);

The above will output:

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

Similar Functions in Other Languages

Was This Helpful?

Previous Post
strtolower()
Next Post
strlen()

0 Comments

Leave a Reply