echo or print

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
macewan
Forum Commoner
Posts: 97
Joined: Mon Jul 07, 2003 8:27 pm

echo or print

Post by macewan »

I am used to using "echo" to print text.

echo "hello";


Should I switch to using print now?

print ("hello");
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post 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
macewan
Forum Commoner
Posts: 97
Joined: Mon Jul 07, 2003 8:27 pm

Post by macewan »

thanks for the quick reply/answer
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

np
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post 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.

Post Reply