aardvark92
Programmer
I've been wondering about this for a while. . .
What, practically speaking, is the difference between the print() and echo() constructs? According to php.net, print returns a value (always 1), while echo does not. Also, print outputs a string, while echo outputs one or more strings.
So I guess the following work:
while these do not:
But the output of multiple strings could be simulated with print by comcatenating them, and the return value could be simulated with echo by assigning $value = 1.
So what I'm trying to get at is, practically speaking, does it make a difference which one is used? Is it more a matter of style? Are there any situations in which print or echo is clearly better than the other?
What, practically speaking, is the difference between the print() and echo() constructs? According to php.net, print returns a value (always 1), while echo does not. Also, print outputs a string, while echo outputs one or more strings.
So I guess the following work:
Code:
$value = print "string"; // $value = 1
echo "two", " strings";
while these do not:
Code:
$value = echo "string";
print "two", " strings";
But the output of multiple strings could be simulated with print by comcatenating them, and the return value could be simulated with echo by assigning $value = 1.
So what I'm trying to get at is, practically speaking, does it make a difference which one is used? Is it more a matter of style? Are there any situations in which print or echo is clearly better than the other?