+ 3
PHP
What is the different between print and print_r(); ?
4 Respuestas
+ 6
The print_r() function is a built-in function in PHP and is used to print or display information stored in a variable.
where echo, print also used for same purpose
+ 6
print_r : - outputs human-readable representation of any one value.
- outputs an array showing keys and values.
- has a return type.(can be used in an expression).
- takes not just string but any value.
echo : - prints a string or a concatenated string
- doesnt have a return type
print_r recursively prints an array , showing all keys and values,while echo doesn't, and is intended for scalar values
+ 3
Yeah right but what is the main different between ?
+ 2
print_r can display array
While print cannot
$arr=[1, 2,3] ;
print_r($arr) ;//no error and will show array
print($are) ;//shows errror