Page 1 of 1

echo or print

Posted: Mon Jul 07, 2003 8:27 pm
by macewan
I am used to using "echo" to print text.

echo "hello";


Should I switch to using print now?

print ("hello");

Posted: Mon Jul 07, 2003 8:37 pm
by m3rajk
i use echo. print is made to give more control... like in perl... echo just takes the quotes, printf allows certain ways of controlling how it prints.

there's no reason for you to switch

Posted: Mon Jul 07, 2003 8:40 pm
by macewan
thanks for the quick reply/answer

Posted: Mon Jul 07, 2003 8:42 pm
by m3rajk
np

Posted: Tue Jul 08, 2003 12:51 am
by nigma
Also, echo can also use what is called the ' here document ' syntax. It will let you print multiple lines to a browser with variable interpolation. An example would be:

echo <<<DOSOMETHING
<h1>Blah Blah, Blah Blah Blah, Blah!</h1>
<br><br>
DO DAH DAY!
DOSOMETHING; /* DOSOMETHING; MUST be at the very beginning of the line, no spaces or tabs before it. */

Real useful if you need to print chunks of html throughout your PHP code.