|
|
Tutorials » Php »
|
Topic |
What is print_r Function and how it is used in string?
|
|
Explanation |
|
print_r function displays the information about a variable in a way that's readable by humans in PHP.
Syntax:
print_r(expression,return)
In the above printr syntax "expression" is to be printed, "return" used to print the return value.
Example:
<?php
$s = array ( array ("name" => "Sam", "Last" => "Anderson"),
array ("City" => "Dallas", "State" => "Texas"));
print_r ($s);
?>
Result:
Array ( [0] => Array ( [name] => Sam [Last] => Anderson )
[1] => Array ( [City] => Dallas [State] => Texas )
)
In the above example for string, we can see that mulitiple arrays are printed in detail, so the printr function goes through
each and every detail of the array.
NOTE:
The "printr" is actually not a function so no need to use the parenthesis.
|
|
A Note |
Learn PHP programming language tutorial with simple and neat example. Hope you enjoy this free tutorial.
Do give us your valuable feedback and suggestions on this online tutorial. This is a Copyright Content.
|
|
|
|