Difference between echo and print_r

hi,
can any1 please tell me the difference between echo and print_r

thank u

From the manual…

print_r() displays information about a variable in a way that’s readable by humans.

echo Outputs all parameters. And echo is not a function, but a language construct.

echo “a string”;

displays “a string” in the browser…

if you have an array with, say 2 elements. called $array…
print_r($array)
displays:
Array ( [0] => “first_element”,
[1] => “second_element”)

where trying to
echo $array
would just output “Array”
because, it doesn’t know what part of the array you want to show…
if you are wondering simply about print() though, it is nearly the same as echo, except slightly slower.

I thought print_r meant “print recursively”, and was mainly for looking inside arrays and objects, it keeps printing till it gets to the end of the contents.

Otherwise you’d use var_dump wouldnt you?

The difference is neglible and in some cases print is faster than echo (when ob_start is enabled for example).
The main difference is that print returns a value so you can use it as part of a complex expression whereas echo cannot.

thank u everyone for ur solutions…