print echo
Moderator: General Moderators
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
print echo
what is the difference between print and echo
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Straight from the manual
echo
(PHP 3, PHP 4, PHP 5 )
echo -- Output one or more strings
Description
void echo ( string arg1 [, string ...] )
Outputs all parameters.
echo() is not actually a function (it is a language construct) so you are not required to use parentheses with it. In fact, if you want to pass more than one parameter to echo, you must not enclose the parameters within parentheses.
(PHP 3, PHP 4, PHP 5 )
print -- Output a string
Description
int print ( string arg )
Outputs arg. Returns 1, always.
print() is not actually a real function (it is a language construct) so you are not required to use parentheses with its argument list.
In real life there is not much difference, which one you use but check this out:
See the difference?
Code: Select all
<?php
$string1="Hello ";
$string2="world";
echo $string1,$string2;
print $string1 . $string2;
?>