+ 3

PHP

What is the different between print and print_r(); ?

18th Jan 2019, 2:26 PM
Gauhar Rahman Niazi
Gauhar Rahman Niazi  - avatar
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
18th Jan 2019, 2:36 PM
Sudarshan Rai
Sudarshan Rai - avatar
+ 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
18th Jan 2019, 9:05 PM
AKS
AKS - avatar
+ 3
Yeah right but what is the main different between ?
18th Jan 2019, 2:53 PM
Gauhar Rahman Niazi
Gauhar Rahman Niazi  - avatar
+ 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
18th Jan 2019, 4:19 PM
ᴋᵘⁿᵃˡ
ᴋᵘⁿᵃˡ - avatar