The echo and print are similar ones as they are not a functions they are the language constructs.
echo
The echo as a language construct it outputs one or more strings. The echo has a void data type.As it is a construct and not a function so it wont require parenthesis.
example :
<?php echo "Hello world"; ?>
print
The print is a language construct, The print is actually a function with return value 1. It can be used in expression.
example :
<?php print("Hello world"); ?>
Note: echo is much faster than print.
print_r
It gives the output in a way which is much easier to be readable by humans. It accepts strings but also arrays and format them in a readable format.It is used mostly in debugging purposes.
example:
<?php
$day = array (m => monday, t' => tuesday, w => 'wednesday');
print_r ($day);
?>
0 Comment(s)